Tweak3D.Net
Save?
Not Registered Yet? Go here.
Join The Cult Tweakers Image Gallery Donate Search Today's Posts Mark Forums Read

Welcome to Tweak3D

This is an open forum about hardware and tech stuff. Sign-up here to join the discussion.

Reply
 
LinkBack Thread Tools Display Modes
Old 02-21-2006, 12:44 PM telephone program in vb   permalink #1
TK6500
FOGO
 
Jan 2005
Last Seen: 01-11-2008
Posts: 571 (#109)
Thanked 0x in 0 posts

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
TK6500 is offline   Reply With Quote
Yesterday, 05:30 PM   #2
 
 


Google is online (hide)  
Old 02-21-2006, 01:55 PM   permalink #2
Jamsan
Tweak Minion
 
Jan 2005
Last Seen: 05-15-2008
Location: Connecticut
Posts: 1,303 (#65)
Thanked 0x in 0 posts

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?
Jamsan is offline   Reply With Quote
Old 02-21-2006, 02:25 PM   permalink #3
TK6500
FOGO
 
Jan 2005
Last Seen: 01-11-2008
Posts: 571 (#109)
Thanked 0x in 0 posts

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
and form 1:
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
TK6500 is offline   Reply With Quote
Old 02-21-2006, 03:53 PM   permalink #4
Jamsan
Tweak Minion
 
Jan 2005
Last Seen: 05-15-2008
Location: Connecticut
Posts: 1,303 (#65)
Thanked 0x in 0 posts

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)
Jamsan is offline   Reply With Quote
Old 09-02-2006, 01:44 PM   permalink #5
darktides's Avatar
darktides
The cable guy.
 
Jan 2005
Last Seen: 05-15-2008
Posts: 151 (#147)
Thanked 0x in 0 posts

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"
darktides is offline   Reply With Quote
Reply

Login to reply. Sign-up here.


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT -7. The time now is 07:04 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0
©Tweak3D.Net 1998-2008Ad Management by RedTyger