|
-
Dec 1st, 2006, 10:05 PM
#1
Thread Starter
Lively Member
[RESOLVED] help help help :0
i have 2 multiline textboxs textbox1,textbox2
textbox1 contain text like this
Code:
I have to go now,i have a lot of work to do
today i will finish it to get high score,i get high score towice
the required code is to get the words betwain "i" and "to" in textbox2 to be like this
Code:
I have to
i have a lot of work to
i will finish it to
-
Dec 1st, 2006, 10:07 PM
#2
Addicted Member
Re: help help help :0
So what exactly to you need help with? Everything???
There are several ways to do this. Assuming this is a school assignment for a beginning class, you proabably will be using the Instr and Mid$ functions.
Look those up and experiment with them, and you will learn how to do this.
Last edited by woodyz; Dec 1st, 2006 at 10:20 PM.
-
Dec 2nd, 2006, 03:57 AM
#3
Re: help help help :0
try this...
VB Code:
Private Sub Command1_Click()
Dim iSPos As Integer
Dim iEPos As Integer
Dim iNextSPos As Integer
Dim iNextEPos As Integer
Dim iLength As Integer
iNextSPos = 1
iNextEPos = 1
iLength = Len(Trim(Text1.Text))
Do While i <= iLength
iSPos = InStr(iNextSPos, Text1.Text, "I ", vbTextCompare)
If iSPos > 0 Then
iEPos = InStr(iNextEPos, Text1.Text, " to ")
If iEPos > 0 Then
Text2.Text = Text2.Text & Mid(Text1.Text, iSPos, (iEPos + 3) - iSPos) & vbCrLf
iNextSPos = iEPos + 3
iNextEPos = iEPos + 3
i = i + iEPos
Else
i = i + 1
End If
Else
i = i + 1
End If
Loop
End Sub
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Dec 2nd, 2006, 10:02 PM
#4
Thread Starter
Lively Member
Re: help help help :0
 Originally Posted by ganeshmoorthy
try this...
VB Code:
Private Sub Command1_Click()
Dim iSPos As Integer
Dim iEPos As Integer
Dim iNextSPos As Integer
Dim iNextEPos As Integer
Dim iLength As Integer
iNextSPos = 1
iNextEPos = 1
iLength = Len(Trim(Text1.Text))
Do While i <= iLength
iSPos = InStr(iNextSPos, Text1.Text, "I ", vbTextCompare)
If iSPos > 0 Then
iEPos = InStr(iNextEPos, Text1.Text, " to ")
If iEPos > 0 Then
Text2.Text = Text2.Text & Mid(Text1.Text, iSPos, (iEPos + 3) - iSPos) & vbCrLf
iNextSPos = iEPos + 3
iNextEPos = iEPos + 3
i = i + iEPos
Else
i = i + 1
End If
Else
i = i + 1
End If
Loop
End Sub
Code:
Thanks for great help
i changed it to be perfect with lines may contains more than one case of the condition
VB Code:
Dim TxT, IStr, ToStr, ILoc, ToLoc, GLoc, Strng
BeStr = " i "
ThisStr = " to "
GLoc = 1
TxT = Text1.Text
For oop = 1 To (Len(TxT) - 1)
ILoc = InStr(GLoc, TxT, IStr, vbTextCompare)
If ILoc > 0 Then
ToLoc = InStr(GLoc, TxT, ToStr, vbTextCompare)
If ToLoc > 0 Then
GLoc = ToLoc + 1
Strng = Mid$(Text1.Text, ILoc + 1, (ToLoc + 3) - ILoc)
Text2.Text = Text2.Text & Strng & vbnewline
Else
oop = oop + 1
End If
Else
oop = oop + 1
End If
Next
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|