Results 1 to 6 of 6

Thread: How to cut the number away?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2006
    Posts
    7

    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.

  2. #2
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2006
    Posts
    7

    Re: How to cut the number away?

    yes, it is always 4 digit.
    How should I use right?
    Thanks!

  4. #4

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2006
    Posts
    7

    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!

  6. #6

    Thread Starter
    New Member
    Join Date
    Aug 2006
    Posts
    7

    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
  •  



Click Here to Expand Forum to Full Width