Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Is anyone good a Visual Basic

  1. #1
    *supposed to be 'at' Visual Basic not a* in the title
    I need help with coding an application that will calculate the square and square root.


    The application must use two forms.
    The first one should prompt the sudent for their name and should resemble a standard dialog box.
    The name must also be displayed on the main form when the main form is run.
    The main form should include a Square/Square Root button, a Print button, and an Exit button.
    Use the InputBox function in the Square/Square Root button to prompt the user for the number. Would I use the function in the text box where the user would input a number or would that also be in the calculate button?
    The application should also display both the square and square root of the number.This is where I mainly need the help.
    How do I go about coding the 'Calculate button' so that when a user is prompted to input a number into a Input box it will will calculate the square and square root of it?

    The print button should send the focus to the Square/Square Root button.

    This is what I have so far. I'm pretty sure about the first part, but am confused about the square root part.



    Code:
    Private Sub cmdCalc_Click()
          ‘calculate square of a number
          lblTsquare.Caption=txtNumber^2
          ‘calculate square root of a number
          txtNumber.Text = Sqr(txtNumber.Text)
    End Sub

  2. #2
    ohh..i wish i could help..but i dunno this.



  3. #3
    It okay :]

    I think it's supposed to be lblTroot.Caption=Sqr(txtNumber.Text) for the square root part ?

  4. #4
    Nevermind, I figured it out. It's supposed to be
    Code:
    Private Sub cmdSquare_Click()
        'calculate square of a number
        lblTSquare.Caption = txtNumber ^ 2
        'calculate square root of a number
        lblTroot.Caption = Sqr(txtNumber.Text)
    
    End Sub
    Now to put the InputBox function in the Square/Square Root button to prompt the user for the number.. I know this, I just have to remember how to do it :]

  5. #5
    hehehe...thank God its done now...



  6. #6
    yeah...and now the InputBox function is killing me..I can't get it for the life for me..and it's such a simple thing..I just can't for the life of me figure out what variable to use and where..AAAAAAAAAH

  7. #7
    So apprently I had the directions all wrong...I need the command button to ask for the number [InputBox] and do the calculations...

    I have both parts figured out separatly, but combining the two is giving me trouble.

  8. #8
    Yes seperately its can be done i see up the code its confusing me when they are combine, may i m only 1% in my math & all that calculations. , i know Some BAsic the basic level only...i really want to learn more but looks difficult now , since last 2 years i not even my basics and almost forgot practical but , i can start now again , a VB Book is on my table since last 2 weeks but i did'nt open...

    From today i will start again , ...I will send u somthing when i m learning befor 2 years for my practice i apply basic VB programs in a VB executable Appliaction...also i have that ssource file...some where in my old backup harddisk.. i will check...

    I m glade to see u r studying VB..

    So from now i m starting and ask u questions...ok

    take care

    see u
    MYK
    www.enjoymenttube.blogspot.com
    www.facebook.com/pages/Enjoyment-Tube/227697370623550?ref=hl
    [SIGPIC][/SIGPIC]

  9. #9
    also befor some months i starts to write tuturial for basic programing with examples ,graphics and sample codes...almost near to cmplete but i dont know when & why i stope that & wheres that file..

    i will look for that now...

    One thing i dont know can u tell me in how to make skins for audio media player in vb ? is that posible... ?
    MYK
    www.enjoymenttube.blogspot.com
    www.facebook.com/pages/Enjoyment-Tube/227697370623550?ref=hl
    [SIGPIC][/SIGPIC]

  10. #10
    Oooh gosh, Programming is not something I enjoy at ALL..I am only learning it because I have to for this degree...Trust me you do not want to ask me questions

    UGH..I so hate coding..especially when you have it all but for one little thing messes it all UP!!!

    Code:
    Private Sub cmdSquare_Click()
        Dim i
        i = InputBox("Please enter a number.", "Input Box")
        MsgBox "The square of " & i & " is " & Sqr(i ^ 2), vbOKOnly, "Result"
        MsgBox "The square root of " & i & " is " & Sqr(i), vbOKOnly, "Result"
        
    End Sub
    I can't get it to do the squared calculations correctly...Somethings wrong, but I can't see what that is

Posting Permissions

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