|
-
Aug 10th, 2006, 03:49 AM
#1
Thread Starter
New Member
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.
-
Aug 10th, 2006, 03:56 AM
#2
Frenzied Member
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.
-
Aug 10th, 2006, 03:58 AM
#3
Thread Starter
New Member
Re: How to cut the number away?
yes, it is always 4 digit.
How should I use right?
Thanks!
-
Aug 10th, 2006, 03:58 AM
#4
Re: How to cut the number away?
-
Aug 10th, 2006, 04:17 AM
#5
Thread Starter
New Member
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!
-
Aug 10th, 2006, 04:18 AM
#6
Thread Starter
New Member
Re: How to cut the number away?
thanks, I fixed it already!
Thanks all!
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
|