Page 2 of 2 FirstFirst 12
Results 26 to 41 of 41

Thread: Creating a .exe

  1. #26
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by sm321 View Post
    I've made an equals button which has made the calculator work, but I've only made work for +. How do I make it work for all 4 +-*/
    That depends on how you coded the function for the equals button. Let me see the code.

  2. #27
    Join Date
    Dec 2011
    Posts
    257
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by ShawnjohnSJ View Post
    That depends on how you coded the function for the equals button. Let me see the code.
    Label2.Text = "+"
    Label1.Text = Val(TextBox1.Text) + Val(TextBox2.Text)

    I just copied and pasted the + button's coding

  3. #28
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by sm321 View Post
    Label2.Text = "+"
    Label1.Text = Val(TextBox1.Text) + Val(TextBox2.Text)

    I just copied and pasted the + button's coding
    You won't be able to do it that way. I can't give you example code because I haven't programmed in Visual Basic in years, but if you look at the YouTube video I posted 2 posts ago, it'll show you how to correctly do it.

  4. #29
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by sm321 View Post
    I've made an equals button which has made the calculator work, but I've only made work for +. How do I make it work for all 4 +-*/
    Well you would have to recode some of your program to make it work for an equals button.. the only reason it works for addition is because you're basically performing the addition twice.

    Give me a few minutes and I'll try to write up some code that'll have an equals button.

    Edit: Try this code.. I don't know if it works because I don't have visual basic installed but it should work. It will only work for 2 numbers. Make sure your equals button is named "Button5"

    Code:
    Dim firstValue as Double
    
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    firstValue = Val(TextBox1.Text)
    Label2.Text = "-"
    End Sub
    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    firstValue = Val(TextBox1.Text)
    Label2.Text = "+"
    End Sub
    
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    firstValue = Val(TextBox1.Text)
    Label2.Text = "x"
    End Sub
    
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    firstValue = Val(TextBox1.Text)
    Label2.Text = "/"
    End Sub
    
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
    Label2.Text = "="
    Label1.Text = firstValue / Val(TextBox2.Text)
    End Sub
    Last edited by ShawnjohnSJ; 02-03-2012 at 06:09 PM.

  5. #30
    Join Date
    Dec 2011
    Posts
    257
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by ShawnjohnSJ View Post
    Well you would have to recode some of your program to make it work for an equals button.. the only reason it works for addition is because you're basically performing the addition twice.

    Give me a few minutes and I'll try to write up some code that'll have an equals button.

    Edit: Try this code.. I don't know if it works because I don't have visual basic installed but it should work. It will only work for 2 numbers. Make sure your equals button is named "Button5"

    Code:
    Dim firstValue as Double
    
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    firstValue = Val(TextBox1.Text)
    Label2.Text = "-"
    End Sub
    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    firstValue = Val(TextBox1.Text)
    Label2.Text = "+"
    End Sub
    
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    firstValue = Val(TextBox1.Text)
    Label2.Text = "x"
    End Sub
    
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    firstValue = Val(TextBox1.Text)
    Label2.Text = "/"
    End Sub
    
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
    Label2.Text = "="
    Label1.Text = firstValue / Val(TextBox2.Text)
    End Sub
    Thanks, I'll try that sometime But I've encountered another problem, I've got this code:
    Val(TextBox2.Text) = Val(TextBox5.Text) - Val(TextBox4.Text) * Val(TextBox6.Text)

    Yet it says 'Expression is a value and therefore cannot be the target of an assignment'.

  6. #31
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by sm321 View Post
    Thanks, I'll try that sometime But I've encountered another problem, I've got this code:
    Val(TextBox2.Text) = Val(TextBox5.Text) - Val(TextBox4.Text) * Val(TextBox6.Text)

    Yet it says 'Expression is a value and therefore cannot be the target of an assignment'.
    TextBox2.Text is a variable. When you do Val(TextBox2.Text) it converts that string into an integer (hence Val=Value).. what you're doing here is setting the integer value of TextBox2.Text to ... which doesn't make any sense.

    To put that into simpler terms, only use Val after the equals sign.

    Code:
    TextBox2.Text = Val(TextBox5.Text) - Val(TextBox4.Text) * Val(TextBox6.Text)

  7. #32
    Join Date
    Dec 2011
    Posts
    257
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by ShawnjohnSJ View Post
    TextBox2.Text is a variable. When you do Val(TextBox2.Text) it converts that string into an integer (hence Val=Value).. what you're doing here is setting the integer value of TextBox2.Text to ... which doesn't make any sense.

    To put that into simpler terms, only use Val after the equals sign.

    Code:
    TextBox2.Text = Val(TextBox5.Text) - Val(TextBox4.Text) * Val(TextBox6.Text)
    It hasn't come up with an error, yet text box 2 is still blank

  8. #33
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by sm321 View Post
    It hasn't come up with an error, yet text box 2 is still blank
    Send me your code via PM and I'll help you.

  9. #34
    Join Date
    Dec 2011
    Location
    Nj
    Posts
    2,341
    Mentioned
    1 Post(s)
    Quoted
    18 Post(s)

    Default

    I agree with Wizzup?, he is a B O S S btw.
    If you want to learn any programming, start with basic or pascal!

    For the basics of the basics of pascal, try my TuT. ||Photoshop Editing ||MapleResourceDung Script || Book a flight! BuySellTrip

  10. #35
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    It may be easy for beginners, but if you begin with stuff like that you'll most of the time never get much further than a beginner... No offense intended.
    Yes, and considering actual VB coding rather than messing with the form designer, it's syntax and ideas are very, very different from the "leading" languages (which future languages are based on).

  11. #36
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    Yes, and considering actual VB coding rather than messing with the form designer, it's syntax and ideas are very, very different from the "leading" languages (which future languages are based on).
    True, the syntax is very different and the idea of event-driven programming gets you into a completely different mindset than if you were programming in C++, Java, etc. What I meant by it being a good language for starters is not having to mess around with creating the code for GUI's (which can be daunting sometimes) and easy manipulation of components on the GUI. Its very easy for someone to jump right in and create a calculator (for example) and learn about variables, expressions, methods, etc. But everyone has different opinions and preferences, I guess its just a matter of where you feel comfortable starting off at.

  12. #37
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    It may be easy for beginners, but if you begin with stuff like that you'll most of the time never get much further than a beginner... No offense intended.
    BASIC was really just designed to teach the use of types, control structures, and the like, in a nice easy manner. I agree that it is good for learning, but disagree to constantly use it for everything.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  13. #38
    Join Date
    Dec 2011
    Posts
    257
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I've had a little practice with it and want to make a Runescape Calculator of some sort, but what should I make?

  14. #39
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by sm321 View Post
    I've had a little practice with it and want to make a Runescape Calculator of some sort, but what should I make?
    RuneScape calculator?
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  15. #40
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    Quote Originally Posted by Daniel View Post
    BASIC was really just designed to teach the use of types, control structures, and the like, in a nice easy manner. I agree that it is good for learning, but disagree to constantly use it for everything.
    To be fair, Pascal was designed as a language for learning, and it's by the far the most used language on this forum. Even Java is used largely as a method of teaching people the ways of OOP, although it is used in some large applications today.

  16. #41
    Join Date
    Dec 2011
    Posts
    257
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Daniel View Post
    RuneScape calculator?
    One that calculates something for Runescape e.g. type in your xp and it tells you time to get a level or something Runescape related.

Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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