Results 1 to 6 of 6

Thread: Please help me

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    9

    Please help me

    Hi I'm new to vb and would like to know the code for doing mathematical equations e.g. adding, multiplying, with textboxes and comboboxes, which saves the answer to a invisible textbox/combobox to be retrieved later
    thanks
    buzzlightyear

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    VB Code:
    1. Private Sub Command1_Click()
    2.     Text2.Text = Val(Text1.Text) + Val(Combo1.Text)
    3. End Sub
    4.  
    5. Private Sub Form_Load()
    6.     Text2.Visible = False
    7. End Sub

    I would store the number in a variable though
    -= a peet post =-

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    9

    Talking

    Thanks peet
    but how do you place brackets in the code as to make one step before the other. e.g. 2+(4-1) and what is the sign for multiplying and where is it placed
    thanks
    buzzlightyear
    Last edited by buzzlightyear; May 19th, 2002 at 05:32 PM.

  4. #4
    Hyperactive Member -=XQ=-'s Avatar
    Join Date
    Mar 2002
    Location
    Liverpool, England, UK
    Posts
    278
    You can do as you have wrote 2+(4-1). ie.

    Code:
    Text2.Text = val(Text3.Text) - (Val(Text1.Text) + Val(Combo1.Text))
    'or
    Text2.Text = 2 + (4 - 1)
    The code follows the same rules of maths... totaling calculations in brackets before calculating the total.
    See ya later,

    -=XQ=-

    "Reality is merely an illusion, albeit a very persistent one. "
    - Albert Einstein (1879-1955)
    This is the coolest site ever!!!

  5. #5
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    Originally posted by -=XQ=-
    You can do as you have wrote 2+(4-1). ie.

    Code:
    Text2.Text = val(Text3.Text) - (Val(Text1.Text) + Val(Combo1.Text))
    'or
    Text2.Text = 2 + (4 - 1)
    The code follows the same rules of maths... totaling calculations in brackets before calculating the total.
    and from left to right.

    The sign for multiplication is the asterisk (*)

    VB Code:
    1. z = x * 5 - (3 * y) / 12

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Brackets, Or, Division, Multiplication, Addition, Subtraction. The same rule follow for math eqn's in VB

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