Click here to Skip to main content
16,005,149 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Help with code for telephone validator Pin
DA_Loring10-Nov-05 0:53
DA_Loring10-Nov-05 0:53 
AnswerRe: Help with code for telephone validator Pin
12String27-Oct-05 11:39
12String27-Oct-05 11:39 
AnswerRe: Help with code for telephone validator Pin
Christian Graus27-Oct-05 15:05
protectorChristian Graus27-Oct-05 15:05 
GeneralRe: Help with code for telephone validator Pin
12String27-Oct-05 16:20
12String27-Oct-05 16:20 
GeneralRe: Help with code for telephone validator Pin
Christian Graus27-Oct-05 16:27
protectorChristian Graus27-Oct-05 16:27 
GeneralRe: Help with code for telephone validator Pin
12String27-Oct-05 16:35
12String27-Oct-05 16:35 
GeneralRe: Help with code for telephone validator Pin
Christian Graus27-Oct-05 16:38
protectorChristian Graus27-Oct-05 16:38 
GeneralRe: Help with code for telephone validator Pin
12String27-Oct-05 16:40
12String27-Oct-05 16:40 
Here is what I have come up with so far and this doesn't quite work. What do you think. I still need to code in VB.NET so therein lays my problem. LOL


Public Class frmMain
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents btnValPhNmb As System.Windows.Forms.Button
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.btnValPhNmb = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(16, 8)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(264, 24)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Enter Phone Number"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'TextBox1
'
Me.TextBox1.Font = New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TextBox1.Location = New System.Drawing.Point(80, 56)
Me.TextBox1.MaxLength = 12
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(128, 26)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = ""
Me.TextBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'btnValPhNmb
'
Me.btnValPhNmb.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnValPhNmb.Location = New System.Drawing.Point(88, 104)
Me.btnValPhNmb.Name = "btnValPhNmb"
Me.btnValPhNmb.Size = New System.Drawing.Size(120, 32)
Me.btnValPhNmb.TabIndex = 2
Me.btnValPhNmb.Text = "Validate Phone Number"
'
'frmMain
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.InactiveCaptionText
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.btnValPhNmb)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label1)
Me.Name = "frmMain"
Me.Text = "Phone Number Validator"
Me.ResumeLayout(False)

End Sub

#End Region


Private Sub btnValPhNmb_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnValPhNmb.Click
'Check length of input string: it must be exactly 12.
'Check Substring(3,1) and Substring(7,1), i.e. the fourth and _
'eighth character must be "-".

Dim TextBox1 As String

CheckInput() 'check to see if input is numeric and between 0 and 11


If TextBox1 = ("999" & "-" & "999" & "-" & "9999") Then
MsgBox("You have entered a correct phone number.")
ElseIf TextBox1 = "999999" & "-" & 9999 Then
MsgBox("You need to enter a " - " between the area code and prefix number.")
ElseIf TextBox1 = "999" & "-" & "9999999" Then
MsgBox("You need to enter a " - " between the prefix and phonenumber.")
End If
End Sub
Public Sub CheckInput()
If (Not IsNumeric(Me.TextBox1.Text)) Then 'checks user input for numeric and range
MsgBox("Please enter a numeric telephone number starting with the area code.")
TextBox1.Text = ""

End If
End Sub
End Class
GeneralRe: Help with code for telephone validator Pin
Christian Graus27-Oct-05 16:44
protectorChristian Graus27-Oct-05 16:44 
GeneralRe: Help with code for telephone validator Pin
12String27-Oct-05 16:48
12String27-Oct-05 16:48 
GeneralRe: Help with code for telephone validator Pin
Christian Graus27-Oct-05 17:11
protectorChristian Graus27-Oct-05 17:11 
GeneralRe: Help with code for telephone validator Pin
12String27-Oct-05 17:14
12String27-Oct-05 17:14 
GeneralRe: Help with code for telephone validator Pin
Christian Graus27-Oct-05 17:23
protectorChristian Graus27-Oct-05 17:23 
GeneralRe: Help with code for telephone validator Pin
12String27-Oct-05 17:26
12String27-Oct-05 17:26 
GeneralRe: Help with code for telephone validator Pin
Christian Graus27-Oct-05 17:27
protectorChristian Graus27-Oct-05 17:27 
GeneralRe: Help with code for telephone validator Pin
12String27-Oct-05 17:31
12String27-Oct-05 17:31 
GeneralRe: Help with code for telephone validator Pin
Christian Graus27-Oct-05 17:34
protectorChristian Graus27-Oct-05 17:34 
GeneralRe: Help with code for telephone validator Pin
12String27-Oct-05 17:41
12String27-Oct-05 17:41 
GeneralRe: Help with code for telephone validator Pin
Christian Graus27-Oct-05 17:48
protectorChristian Graus27-Oct-05 17:48 
GeneralRe: Help with code for telephone validator Pin
Steve Pullan27-Oct-05 18:38
Steve Pullan27-Oct-05 18:38 
GeneralRe: Help with code for telephone validator Pin
Christian Graus27-Oct-05 18:41
protectorChristian Graus27-Oct-05 18:41 
GeneralRe: Help with code for telephone validator Pin
Dave Kreskowiak28-Oct-05 4:58
mveDave Kreskowiak28-Oct-05 4:58 
GeneralRe: Help with code for telephone validator Pin
Christian Graus30-Oct-05 11:13
protectorChristian Graus30-Oct-05 11:13 
QuestionRe: Help with code for telephone validator Pin
seee sharp27-Oct-05 19:12
seee sharp27-Oct-05 19:12 
AnswerRe: Help with code for telephone validator Pin
12String27-Oct-05 19:13
12String27-Oct-05 19:13 

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.