Click here to Skip to main content
15,894,343 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: What was the solution ? Pin
Bob Stanneveld30-Sep-11 9:20
Bob Stanneveld30-Sep-11 9:20 
AnswerRe: datagridview button column - text not displaying [Solved] Pin
Ajit Yagnesh23-Feb-11 1:38
Ajit Yagnesh23-Feb-11 1:38 
GeneralRe: datagridview button column - text not displaying [Solved] Pin
Simon_Whale23-Feb-11 1:40
Simon_Whale23-Feb-11 1:40 
QuestionOffice interop printing problem Pin
mSh198530-Mar-10 22:06
mSh198530-Mar-10 22:06 
Questionhelp with displaying hierarchical data in treeview in Visual Basic 2005 Pin
kim67830-Mar-10 21:10
kim67830-Mar-10 21:10 
QuestionNewbie to VB Pin
willwilco30-Mar-10 15:10
willwilco30-Mar-10 15:10 
AnswerRe: Newbie to VB Pin
_Damian S_30-Mar-10 16:05
professional_Damian S_30-Mar-10 16:05 
AnswerRe: Newbie to VB Pin
Wayne Gaylard30-Mar-10 20:38
professionalWayne Gaylard30-Mar-10 20:38 
As Damian S said, you can use regular expressions in VB.Net. Try this function :

Private Function ValidatePhoneNumber(ByVal StringToTest As String) As Boolean

    Dim expression As New Regex("(\(\d{3}\)|\d{3})[- ]\s?\d{3}[- ]\d{4}")
    Dim match As Match = expression.Match(StringToTest)
    If match.Success Then
        Return True
    Else
        Return False
    End If

End Function


Then you can call your function like this :

If TextBox1.Text <> String.Empty Then
       If ValidatePhoneNumber(TextBox1.Text) Then
           MsgBox("Correct phone number.")
       Else
           MsgBox("Not valid phone number")
       End If
   End If


If you want to learn more about regular expressions then I recommend you download a copy of Expresso (google it). It is an excellent tool for learning them.

Hope this helps.
GeneralRe: Newbie to VB Pin
willwilco31-Mar-10 13:41
willwilco31-Mar-10 13:41 
AnswerRe: Newbie to VB Pin
The Man from U.N.C.L.E.31-Mar-10 7:07
The Man from U.N.C.L.E.31-Mar-10 7:07 
GeneralRe: Newbie to VB Pin
willwilco31-Mar-10 13:42
willwilco31-Mar-10 13:42 
QuestionTwo RadioButtonList.SelectedIndex Values Changed Simultaneously - What am I Doing Wrong? Pin
johnaparker30-Mar-10 11:11
johnaparker30-Mar-10 11:11 
AnswerRe: Two RadioButtonList.SelectedIndex Values Changed Simultaneously - What am I Doing Wrong? Pin
pdnet1-Apr-10 21:46
pdnet1-Apr-10 21:46 
GeneralRe: Two RadioButtonList.SelectedIndex Values Changed Simultaneously - What am I Doing Wrong? Pin
johnaparker3-Apr-10 4:28
johnaparker3-Apr-10 4:28 
Questionhow can i catch form event keydown if my form has datagridview control ? Pin
xingselex30-Mar-10 6:36
xingselex30-Mar-10 6:36 
AnswerRe: how can i catch form event keydown if my form has datagridview control ? Pin
Abhinav S30-Mar-10 6:48
Abhinav S30-Mar-10 6:48 
AnswerRe: how can i catch form event keydown if my form has datagridview control ? Pin
dan!sh 30-Mar-10 6:49
professional dan!sh 30-Mar-10 6:49 
QuestionVB 2008 DataGridView Pin
Filippo197430-Mar-10 5:46
Filippo197430-Mar-10 5:46 
AnswerRe: VB 2008 DataGridView Pin
dan!sh 30-Mar-10 6:12
professional dan!sh 30-Mar-10 6:12 
AnswerRe: VB 2008 DataGridView Pin
Filippo197430-Mar-10 6:18
Filippo197430-Mar-10 6:18 
GeneralRe: VB 2008 DataGridView Pin
Filippo197430-Mar-10 10:12
Filippo197430-Mar-10 10:12 
GeneralRe: VB 2008 DataGridView Pin
Sebastian Br.31-Mar-10 21:37
Sebastian Br.31-Mar-10 21:37 
AnswerRe: VB 2008 DataGridView Pin
William Winner30-Mar-10 11:04
William Winner30-Mar-10 11:04 
AnswerRe: VB 2008 DataGridView Pin
William Winner30-Mar-10 11:08
William Winner30-Mar-10 11:08 
QuestionCreate autowidth() Property Pin
nyt197230-Mar-10 1:32
professionalnyt197230-Mar-10 1:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.