Pretearg4
11-08-2005, 11:56 PM
I'm working on a project in school using Visual Basic. Heres what I'm supposed to do for those who dont know what I'm trying to make.
http://img30.imageshack.us/img30/30...lculator7dk.png
This is programed for Visual Basic Okay, I worked on this at school today, and heres what I've done so far. I have two questions and after that I think I can do the rest of it. Heres my code so far:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Computer Programing - Misigoy Pd. 7 - November 8 - Project 7'
Sub Main()
'Introduction'
Do
Operate$ = InputBox("Please choose the operation you would like to perform (Case sensitve: TYPE EXACT TEXT)." & vbCrLf & "Addition" & vbCrLf & "Subtraction" & vbCrLf & "Multiplication" & vbCrLf & "Division" & vbCrLf & "Combine" & vbCrLf & "Exit")
Num1# = InputBox("Please enter a number.")
Num2# = InputBox("Please enter a number.")
'Cases'
Select Case Operate$
Case "Addition"
MsgBox ("Addition Operator:" & vbCrLf & Num1# + Num2#)
Case "Subtraction"
MsgBox ("Subtraction Operator:" & vbCrLf & Num1# - Num2#)
Case "Multiplication"
MsgBox ("Multiplication Operator:" & vbCrLf & Num1# * Num2#)
Case "Division"
MsgBox ("Division Operator:" & vbCrLf & Num1# / Num2#)
Case "Combine"
MsgBox ("Combine Operator:" & vbCrLf & Num1# & Num2#)
'The User enters "Exit"'
End Select
Loop Until (Operate$ = "Exit")
'Ending Message'
Done$ = MsgBox("Quit Calculator.")
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Question 1: There is something wrong with my "Exit" option.... When the user types in exit and presses enter to quit the program, how do I make only the ending message come up?
Question 2: My teacher told us that we had to make a function for each operator......... How do you do that I know you have to make a seperate Sub Main() thingy for it but I'm confused about the rest.
http://img30.imageshack.us/img30/30...lculator7dk.png
This is programed for Visual Basic Okay, I worked on this at school today, and heres what I've done so far. I have two questions and after that I think I can do the rest of it. Heres my code so far:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Computer Programing - Misigoy Pd. 7 - November 8 - Project 7'
Sub Main()
'Introduction'
Do
Operate$ = InputBox("Please choose the operation you would like to perform (Case sensitve: TYPE EXACT TEXT)." & vbCrLf & "Addition" & vbCrLf & "Subtraction" & vbCrLf & "Multiplication" & vbCrLf & "Division" & vbCrLf & "Combine" & vbCrLf & "Exit")
Num1# = InputBox("Please enter a number.")
Num2# = InputBox("Please enter a number.")
'Cases'
Select Case Operate$
Case "Addition"
MsgBox ("Addition Operator:" & vbCrLf & Num1# + Num2#)
Case "Subtraction"
MsgBox ("Subtraction Operator:" & vbCrLf & Num1# - Num2#)
Case "Multiplication"
MsgBox ("Multiplication Operator:" & vbCrLf & Num1# * Num2#)
Case "Division"
MsgBox ("Division Operator:" & vbCrLf & Num1# / Num2#)
Case "Combine"
MsgBox ("Combine Operator:" & vbCrLf & Num1# & Num2#)
'The User enters "Exit"'
End Select
Loop Until (Operate$ = "Exit")
'Ending Message'
Done$ = MsgBox("Quit Calculator.")
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Question 1: There is something wrong with my "Exit" option.... When the user types in exit and presses enter to quit the program, how do I make only the ending message come up?
Question 2: My teacher told us that we had to make a function for each operator......... How do you do that I know you have to make a seperate Sub Main() thingy for it but I'm confused about the rest.