How to cut the number away?
I created a database in txt.like this:
"143483",1234
"143484",1235
"143485",5588
"143486",5876
"143488",8568
"143487",8756
I want the if the iput is 143483, then the output is 1234
But now if I input 143483, I got "143483", 1234.
Private Sub Command1_Click()
Dim Target As String
Dim Current As String
Target = Text1.Text
Open "Test1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, Current
If InStr(Current, Target) Then
Label3.Enabled = True
Text2.Enabled = True
Text2.Text = Current
Exit Do
End If
Loop
Close #1
End sub
How could I get 1234 only. thanks a lot.
Re: How to cut the number away?
is the second number always 4 digits?
In that case, use Right to return the four rightmost characters of the string.
If the number of digits changes, use Instr to find the position of the comma and then use Right to return what is behind the comma.
Re: How to cut the number away?
yes, it is always 4 digit.
How should I use right?
Thanks!
Re: How to cut the number away?
Re: How to cut the number away?
why I add this code in, still not work:
[/Highlight]
Private Sub Command1_Click()
Dim Target As String
Dim Current As String
Target = Text1.Text
Open "Test1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, Current
If InStr(Current, Target) Then
Label3.Enabled = True
Text2.Enabled = True
Right=(Current,4)
Text2.Text = Current
Exit Do
End If
Loop
Close #1
End Sub
How should I use this code?
Thanks again!
Re: How to cut the number away?
thanks, I fixed it already!
Thanks all!