Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11

Thread: VB Help

  1. #1
    New to the CF scene
    Join Date
    Feb 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VB Help

    I am fairly new to VB and I have a simple question, I want to begin creating a calculator, but I am stuck at one simple road block, I cant seem to make it so that when you push a number and then another number both appear in the text box. When I hit a number, it shows, when I hit another the first one is removed and the new one shows, any suggestions? Thanks

  • #2
    New to the CF scene
    Join Date
    Feb 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I was thinking of using arrays but I am not sure how they work.

  • #3
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    VB6 or .NET? You'd get the value in it, and concatenate the new number.

    Text1.Text = Text1.Text & 2

    In .NET you can use &=

    Text1.Text &= 2
    Last edited by Brandoe85; 02-15-2005 at 04:45 AM. Reason: Added something...

  • #4
    Regular Coder
    Join Date
    Oct 2004
    Location
    In front of this computer. (Where else?)
    Posts
    442
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Remember to convert the values to integers before performing your calculations.
    Tomorrow is the first day of the rest of your life... What have you done today?
    Tutorials
    Web: w3schools, htmldog General tips: Hardware, Networking

  • #5
    New to the CF scene
    Join Date
    Feb 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you, I am using VB 6, so I can use the & statment?

  • #6
    Regular Coder
    Join Date
    Oct 2004
    Location
    In front of this computer. (Where else?)
    Posts
    442
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Revizx
    Thank you, I am using VB 6, so I can use the & statment?
    Yeah, works perfectly, just tested it myself.
    Text1.Text = Text1.Text & 2
    Tomorrow is the first day of the rest of your life... What have you done today?
    Tutorials
    Web: w3schools, htmldog General tips: Hardware, Networking

  • #7
    New to the CF scene
    Join Date
    Feb 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It works, Thank you very much!
    Last edited by Revizx; 02-15-2005 at 07:19 PM.

  • #8
    New to the CF scene
    Join Date
    Feb 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok another question, how would I go about coding the action of the numbers in the text box to be added, subtracted, multipled, etc?

  • #9
    Regular Coder
    Join Date
    Oct 2004
    Location
    In front of this computer. (Where else?)
    Posts
    442
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Do you have MSDN installed? I'll advise you to do a search on integer operators. If you got any problems after that you can repost
    Tomorrow is the first day of the rest of your life... What have you done today?
    Tutorials
    Web: w3schools, htmldog General tips: Hardware, Networking

  • #10
    New to the CF scene
    Join Date
    Feb 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I dont think I have it installed

  • #11
    Regular Coder
    Join Date
    May 2004
    Location
    New Hampshire, America
    Posts
    246
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Say you want to add two numbers together, you could use this:

    Code:
    ' (Var1 and Var2 pre-initialized with values, of course!)
    dim intResult as Integer
    intResult = Val(Var1) + Val(Var2)
    ' This simple code also assumes that Var1 and Var2 are strings, if they aren't:
    dim intResult as Integer
    intResult = Var1 + Var2
    
    'Next you might want to put the result in, say, a label. Here's how:
    lblFakeLabel.Caption = Str(intResult)
    There's some basic code to play with, but as you yourself said:
    Quote Originally Posted by Revizx
    I am new to VB
    You can easily change the plus to a minus, division, or muiltiplication. Just don't forget to check for division by zero!
    Last edited by Dunna; 02-19-2005 at 01:18 AM.


  •  

    Posting Permissions

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