Results 1 to 7 of 7

Thread: [RESOLVED] I want only 1 "," in a row of numbers

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Location
    Netherlands
    Posts
    71

    Resolved [RESOLVED] I want only 1 "," in a row of numbers

    Hi, i am making a caculater, and 1 of the buttons you can click is one with the
    "," for broken numbers. What I want is that you can only add 1 "," in a row of
    numbers. So I am looking for a code, that looks if there is already a "," in the
    row of numbers in the textbox add that moment. If it is, DON'T add a "," again.
    Last edited by ///Jeffrey\\\; Mar 4th, 2007 at 05:03 AM.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Location
    Netherlands
    Posts
    71

    Re: I want only 1 "," in a row of numbers

    srry, i meant "AT that moment" :-)

  3. #3
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Talking Re: I want only 1 "," in a row of numbers

    Hai,
    What about this piece of code?

    [vbcode]
    Private Sub Command1_Click()
    Dim strnumrow As String
    Dim rslt As Integer
    strnumrow = "1232,1213"
    rslt = InStr(1, strnumrow, ",")
    If rslt > 0 Then
    MsgBox "found"
    Else
    MsgBox "not found"
    End If
    End Sub

    [/vbcode]

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Location
    Netherlands
    Posts
    71

    Re: I want only 1 "," in a row of numbers

    euhm... strnumrow = "1232,1213"
    is that for al kind of lengts? because here are 8 numerbers and in the middle
    a ",". It does also work for 233233224,56 and 34,34343443 ect. ?

  5. #5
    Junior Member Spodi's Avatar
    Join Date
    Jul 2003
    Location
    Washington, USA
    Posts
    18

    Re: I want only 1 "," in a row of numbers

    If you look two lines up, "strnumrow" in this example is just a string variable, not some kind of special VB command or anything. The InStr() function will tell you if one string is in another string. As shown by Fazi, if "," is in strnumrow, the function will return non-zero. I believe the function returns the position it finds the string. So using InStr(), you can see if it exists in the string before adding it.

  6. #6
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: I want only 1 "," in a row of numbers

    [QUOTE=///Jeffrey\\\It does also work for 233233224,56 and 34,34343443 ect. ?[/QUOTE]

    No problem !!

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Location
    Netherlands
    Posts
    71

    Re: [RESOLVED] I want only 1 "," in a row of numbers

    Tnx :d

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