|
-
Dec 6th, 1999, 11:29 PM
#1
Thread Starter
Addicted Member
I need to extract the first word from data in a text box (up to the first space) to use in an sql statement. What is the best way to do this?
-
Dec 6th, 1999, 11:41 PM
#2
Junior Member
Add a command button, a text box and try this code.
Private Sub Command1_Click()
Dim mytext As String
Dim counter As Integer
mytext = Text1.Text
For counter = 1 To Len(Text1.Text)
If Mid$(mytext, counter, 1) = " " Then
GoTo NextPart
End If
Next counter
NextPart:
MsgBox "'" + Mid$(mytext, 1, counter - 1) + "'"
End Sub
Good Luck,
dmuir
-
Dec 6th, 1999, 11:45 PM
#3
Lively Member
Try this...
Dim sFirstWord As String
Dim nPosition As Integer
nPosition = InStr(1, Text1.Text, " ")
If nPosition <> 0 Then
sFirstWord = Left(Text1.Text, nPosition)
Else
sFirstWord = Text1.Text
End If
MsgBox sFirstWord
-
Dec 8th, 1999, 01:52 AM
#4
Member
Two text boxes. A command button.
Add the following code.
Code:
Private Sub Command1_Click()
Dim sword As String
Dim sspace As String
sword = Trim$(Text2.Text)
sspace = InStr(sword, " ")
Text1.Text = Left$(sword, sspace - 1)
End Sub
Ruchi
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
|