12 Replies - 1359 Views - Last Post: 31 July 2009 - 04:55 AM Rate Topic: -----

#1 hemalv  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-July 09

Looping throught a textbox

Post icon  Posted 30 July 2009 - 02:31 AM

Hi,

I am having a little problem with looping through a textbox until i find all the data i need.

I have tried using the Do / Do While and Do Until loops but it crashes.


 Do

			TextBox2.Text = Mid$(TextBox1.Text, InStr(1, TextBox1.Text, "[") + 1, InStr(1, TextBox1.Text, "]") - 2)

		Loop Until Textbox.1.text EOF()



I dont think that the EOF is needed but i am not sure what else i could do.
Note.: The textbox1 - has multiple lines

This post has been edited by hemalv: 30 July 2009 - 02:32 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Looping throught a textbox

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Looping throught a textbox

Posted 30 July 2009 - 04:04 AM

is this a richtextbox or textbox with multy line ?
Was This Post Helpful? 0
  • +
  • -

#3 hemalv  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-July 09

Re: Looping throught a textbox

Posted 30 July 2009 - 04:10 AM

View PostNoBrain, on 30 Jul, 2009 - 03:04 AM, said:

is this a richtextbox or textbox with multy line ?


The text box is multiline text box. And the text looks like the following:

[SEL6]
SUBSID=0x34
TYPE=0x2
Col0=0
Col1=16776960
Col2=255
Col3=51200
Col4=16777215
FHeight=12
FFlags=0
FSet=255
FName=Terminal
PosX=-1
PosY=-1
SizX=402
SizY=340
Status=Nrm
HAPIName=A
[SERVER]
SESSIONS=SW0R
INACTIVE=
FKEY1=
FKEY2=
FKEY3=
FKEY4=
FKEY5=
FKEY6=
FKEY7=
FKEY8=
FKEY9=
FKEY10=
FKEY11=
FKEY12=
ENCAP1=10.38.42.19
ENCAP2=10.38.42.19
XID=020606009032
[SW0R]
SUBSID=0x24

I need to code to search through the whole text box and pull out text with [] e.g.: [SW0R] / [SERVER] / [SEL6]

But currently it only picks out [SEL6].

Any help would be much appreciated.
Was This Post Helpful? 0
  • +
  • -

#4 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Looping throught a textbox

Posted 30 July 2009 - 04:59 AM

a code how to search the textbox
Private Sub Command1_Click()
	Dim i As Integer
	Dim l As Integer
	Dim strbuf As String
	Dim bStop As Boolean
	
	strbuf = Text1.Text
	i = 1
	bStop = False
	
	Do While bStop = False
	l = InStr(i, strbuf, vbCrLf)
	If Not l = 0 Then
		Text2.Text = Text2.Text & Mid(strbuf, i, l - 1) & "/"
		strbuf = Mid$(strbuf, l + 2)
	Else
		Text2.Text = Text2.Text & strbuf
		bStop = True
	End If
	i = 1
   Loop
End Sub



all you have to do is too put the if statement for words that are in [] to be writen only

This post has been edited by NoBrain: 30 July 2009 - 04:59 AM

Was This Post Helpful? 0
  • +
  • -

#5 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Looping throught a textbox

Posted 30 July 2009 - 07:11 AM

dose it work?
Was This Post Helpful? 0
  • +
  • -

#6 hemalv  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-July 09

Re: Looping throught a textbox

Posted 30 July 2009 - 07:14 AM

View PostNoBrain, on 30 Jul, 2009 - 06:11 AM, said:

dose it work?


Hi,

Thanks for the code. Ive put it in and at the moment it copies everything. Just trying to do the code for the [] only.
Was This Post Helpful? 0
  • +
  • -

#7 hemalv  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-July 09

Re: Looping throught a textbox

Posted 31 July 2009 - 02:38 AM

Hi,

Sorry about this but i need your help again. I am not very good a VB.

I tried to only write the text in the [] in the textbox2.text but i am having no luck.

Below is the code so far:



		Dim i As Integer
		Dim l As Integer
		Dim strbuf As String
		Dim bStop As Boolean
		Dim q As String




		strbuf = TextBox1.Text
		i = 1
		bStop = False

		q = Mid$(TextBox1.Text, InStr(1, TextBox1.Text, "[") + 1, InStr(1, TextBox1.Text, "]") - 2)






		Do While bStop = False
			If TextBox1.Text.Contains(q) Then
				l = InStr(i, strbuf, vbCrLf)

				If Not l = 0 Then

					TextBox2.Text = TextBox2.Text & Mid(strbuf, i, l - 1) & "/"

					strbuf = Mid$(strbuf, l + 2)

				Else

					TextBox2.Text = TextBox2.Text & strbuf

					bStop = True

				End If

				i = 1
			End If
		Loop



Sorry about this but i need your help again.
Was This Post Helpful? 0
  • +
  • -

#8 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: Looping throught a textbox

Posted 31 July 2009 - 03:43 AM

think it's in vb.net
use the indexof function to attain your need
Was This Post Helpful? 0
  • +
  • -

#9 hemalv  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-July 09

Re: Looping throught a textbox

Posted 31 July 2009 - 03:54 AM

View Postthava, on 31 Jul, 2009 - 02:43 AM, said:

think it's in vb.net
use the indexof function to attain your need


Hi,

I tried the indexof function but unfortunately i am using VB6 so it doesn’t exist.
Was This Post Helpful? 0
  • +
  • -

#10 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Looping throught a textbox

Posted 31 July 2009 - 03:58 AM

:) no it is not

Private Sub Command1_Click()
Dim l As Integer
Dim strbuf As String
Dim i As Integer
Dim bstop As Boolean
strbuf = TextBox1.Text
i = 1
Do While bstop = False
				l = InStr(i, strbuf, vbCrLf)

				If Not l = 0 Then
					Debug.Print Mid$(strbuf, i, l - 1)
					If InStr(1, Mid$(strbuf, i, l - 1), "[") Then
						TextBox2.Text = TextBox2.Text & Mid(strbuf, i, l - 1) & "/"
					End If
					strbuf = Mid$(strbuf, l + 2)

				Else
					If InStr(1, Mid$(strbuf, i), "[") Then
						TextBox2.Text = TextBox2.Text & strbuf
					End If
					bstop = True

				End If

				i = 1
		Loop
End Sub




i hope this work good luck

This post has been edited by NoBrain: 31 July 2009 - 03:58 AM

Was This Post Helpful? 0
  • +
  • -

#11 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Looping throught a textbox

Posted 31 July 2009 - 04:16 AM

did it work ?
Was This Post Helpful? 0
  • +
  • -

#12 hemalv  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-July 09

Re: Looping throught a textbox

Posted 31 July 2009 - 04:46 AM

View PostNoBrain, on 31 Jul, 2009 - 03:16 AM, said:

did it work ?



hi,

just tried it now it works.

you are brilliant.

Thank you so much
Was This Post Helpful? 0
  • +
  • -

#13 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Looping throught a textbox

Posted 31 July 2009 - 04:55 AM

:) no problem
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1