hi,

I worked around to modifying regular expression below but i could't get what I need. I google it, many things found but not for what i want.

Dim valid AS Boolean = Regex.IsMatch(TextBox1.Text, "^(,?\d+){0,20}$")

Allow numbers exactly like 32,1,6,32,12,21,21,54,675,8,4,3,2,9,0,21,21,21,43,744 in TextBox1. Perfect.

NOW i want 20 numbers as but this time "real numbers" (of type double), separated by commas in TextBox2 like
(32.43343,1.43,6.0,32.434334,12.43432,21.8776,21.89,54.22,675.1232,8.453,4.5454,3.87,2.00,9.65,0.0,21.12,21.2,21.1,43.5,744.3633).

Please help me out.

thanks ...

does it have to be a regular expression?

this code will do its job too and you can tell the user which "number" is wrong though

For Each s As String In TextBox1.Text.Split(",")
            Dim d As Double
            If Not Double.TryParse(s, d) Then
                MsgBox(s & " is not a double")
            End If
Next

Splendid! it doesn't have to be RexEx and i use this its returns those that aren't double. tnx

But here is what i want:

- exactly 20 real numbers
- separated by comma ","

see the above example.

thanks

yes and?

dim tmp() as string= TextBox1.Text.Split(",")
 If tmp.Length <> 20 Then
            MsgBox("numbers are not exact 20")
        End If
For Each s As String In tmp
            Dim d As Double
            If Not Double.TryParse(s, d) Then
                MsgBox(s & " is not a double")
            End If
Next

yes and?

dim tmp() as string= TextBox1.Text.Split(",")
 If tmp.Length <> 20 Then
            MsgBox("numbers are not exact 20")
        End If
For Each s As String In tmp
            Dim d As Double
            If Not Double.TryParse(s, d) Then
                MsgBox(s & " is not a double")
            End If
Next

SPlendid Geek!

THank you very much.

This article has been dead for over six months. Start a new discussion instead.