Results 1 to 5 of 5

Thread: [RESOLVED] Noob here and I need some simple help

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    3

    Resolved [RESOLVED] Noob here and I need some simple help

    OK im new to this sight and could use some help. I am Makeing a simple program that will work but if you donot put ant thing in the spacesit messes up. its pretty much a a program for easy use of the distance formula.

    heres the code i have all i need to program in is some way if the box is left blank then it equals 0

    Private Sub cmdAdd_Click()
    X1 = txtX1.Text
    Y1 = txtY1.Text
    X2 = txtX2.Text
    Y2 = txtY2.Text
    B = (X1 - X2) ^ 2 + (Y1 - Y2) ^ 2
    B = Sqr(B)
    picAnswer.Print B
    End Sub

    if you guys can help I would really apprieate it
    Last edited by Hack; Jan 30th, 2006 at 06:53 AM.
    <-Sythe-<<

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Noob here and I need some simple help

    Welcome to VBF!

    You can try something like this...

    VB Code:
    1. If Len(txtX1.Text) = 0 Then
    2.     X1 = 0
    3. Else
    4.     X1 = txtX1.Text
    5. End If
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    3

    Red face Re: Noob here and I need some simple help

    that dident work my main problem is leaving the Text boxes blank and not having numbers in them If there was just a way to have a zero permantly put in front of the text box and only make it so you can type numbers. I need to get this because my teacher trys to crash the programs. Thanks
    <-Sythe-<<

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Noob here and I need some simple help

    You may try the validate event of your textboxes...

    VB Code:
    1. Private Sub txtX1_Validate(Cancel As Boolean)
    2.     If Len(txtX1) = 0 Then
    3.         txtX1.Text = "0"
    4.     Else
    5.         If Not IsNumeric(txtX1) Then
    6.             txtX1.Text = "0"
    7.         End If
    8.     End If
    9. End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    3

    Talking Re: Noob here and I need some simple help

    cool cool that helped me, thanks man
    <-Sythe-<<

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width