| |
| | |
| Join The Cult | Tweakers | Image Gallery | Donate | Search | Today's Posts | Mark Forums Read | |
Welcome to Tweak3DThis is an open forum about hardware and tech stuff. Sign-up here to join the discussion. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | telephone program in vb | permalink #1 |
| FOGO | how do i display a telephone number in the form of (123)456-7890. basically i have a text box and number pad where once the length of the textbox exceeds 3 then the number displays as 123-4567 but how do i display the number with the area code if the first number put in is 1. do i use the method IndexOf(digit, start position) within an if else statement? heres my current code: theres other forms and more code but i didnt think it was necessary. thanks Code: Sub dial(ByVal num As Integer)
'Add the number to the result, with a hyphen in its fourth position.
If number.Length = 3 Then
number &= "-"
End If
number &= CStr(num)
textOutput.Text = number
'give focus to Enter button if either 7 digits or 11 digits are entered
If number.Length = 8 Then
buttonEnter.Focus()
ElseIf number.Length = 12 Then
buttonEnter.Focus()
End If
End Sub | |
| | | |
| | #2 |
| | |
| | |
| | permalink #2 | |
| Tweak Minion | Post all your code if you can, and I'll take a look at it when I get home ... do you want it to just add hypens between the xxx-xxx-xxxx? or do you need it for the 1 portion of the area code as well, such as, 1-xxx-xxx-xxxx? | |
| | | |
| | permalink #3 | |
| FOGO | as it says directly on my lab: "display the telephone numbers either in the form xxx-xxx or (xxx)xxx-xxxx. Currently the numbers are only displayed as xxx-xxxx. (As with land side phones, if first digit entered is 1, then the area code must be entered.) For no area code numbers, limit the numer of digits to 7; with area code, limit to 11(1 plus a 10-digit phone number)" Code: Option Strict On
Public Class Form2
Inherits System.Windows.Forms.Form
Public number As String = "" ' Declared Public (verses Dim) so it can be used by any Form
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
dial(1) ' A call to subroutine dial with parameter 1
End Sub
Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
dial(2) ' A call to subroutine dial with parameter 2
End Sub
Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button3.Click
dial(3) ' A call to subroutine dial with parameter 3
End Sub
Private Sub button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button4.Click
dial(4) ' A call to subroutine dial with parameter 4
End Sub
Private Sub buttonn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button5.Click
dial(5) ' A call to subroutine dial with parameter 5
End Sub
Private Sub button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button6.Click
dial(6) ' A call to subroutine dial with parameter 6
End Sub
Private Sub button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button7.Click
dial(7) ' A call to subroutine dial with parameter 7
End Sub
Private Sub button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button8.Click
dial(8) ' A call to subroutine dial with parameter 8
End Sub
Private Sub buttonn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button9.Click
dial(9) ' A call to subroutine dial with parameter 9
End Sub
Private Sub button0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button0.Click
dial(0) ' A call to subroutine dial with parameter 0
End Sub
Sub dial(ByVal num As Integer)
'Add the number to the result, with a hyphen in its fourth position.
If number.Length = 3 Then
number &= "-"
End If
number &= CStr(num)
textOutput.Text = number
'give focus to Enter button if either 7 digits or 11 digits are entered
If number.Length = 8 Then
buttonEnter.Focus()
ElseIf number.Length = 12 Then
buttonEnter.Focus()
End If
End Sub
Private Sub buttonnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonClear.Click
'Clear the output.
textOutput.Clear()
number = ""
End Sub
Private Sub buttonEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonEnter.Click
'Make form2 disappear. The number dialed will then appear in form1's text box.
Me.Close()
End Sub
End Class Code: Option Strict On '
Public Class Form1
Inherits System.Windows.Forms.Form
'Display the second form, and get the telephone number.
Dim secondForm As New Form2
Dim thirdForm As New Form3
Private Sub buttonShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonShow.Click
secondForm.ShowDialog()
'After the second form is closed, display the value of
'its Public variable number in the first form's text box.
textOutput.Text = secondForm.number
buttonDial.Focus()
End Sub
Private Sub buttonExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonExit.Click
Me.Close()
End Sub
Private Sub buttonDial_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonDial.Click
thirdForm.labelShow.Text = "Dialing ..." & secondForm.number
thirdForm.ShowDialog()
textOutput.Clear()
buttonExit.Focus()
End Sub
End Class | |
| | | |
| | permalink #4 | |
| Tweak Minion | Sounds like you can do what you want with the Indexof... Just find out the first number is, and always go down that path in the dial method. That way, you can have it specific the way they are dialing the number (with or without the area code) | |
| | | |
| | permalink #5 | |
| The cable guy. | sounds like the stuff i did at ITT | |
| "A marriage can't be based on anything so transitory as physical attraction. For the long haul you must build on something that will outlast time, like revenge." "Formerly Pitmaster joined in 2001" | ||
| | | |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| a program to snapshoot from a video source? | pk_volt | Tech | 0 | 01-08-2006 07:19 PM |
| program to show video card temp? | emltwnty2 | Tech | 3 | 10-31-2005 08:58 AM |
| Anybody know a program that can act like a mixer? | Sparky | Tech | 4 | 10-23-2005 08:10 AM |
| hotkey/binding program for windows xp | pk_volt | Tech | 1 | 10-10-2005 09:16 PM |
| forgotten program name (firewall thingie?) | log1c | Tech | 6 | 08-05-2005 10:39 AM |