|
-
Mar 4th, 2007, 03:45 AM
#1
Thread Starter
Lively Member
[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.
-
Mar 4th, 2007, 03:46 AM
#2
Thread Starter
Lively Member
Re: I want only 1 "," in a row of numbers
srry, i meant "AT that moment" :-)
-
Mar 4th, 2007, 04:04 AM
#3
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]
-
Mar 4th, 2007, 04:08 AM
#4
Thread Starter
Lively Member
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. ?
-
Mar 4th, 2007, 04:23 AM
#5
Junior Member
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.
-
Mar 4th, 2007, 04:34 AM
#6
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 !!
-
Mar 4th, 2007, 05:03 AM
#7
Thread Starter
Lively Member
Re: [RESOLVED] I want only 1 "," in a row of numbers
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
|