![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
|
Console Problems
Module Module1
Sub Main()
Console.Title = "Speech Calculator Demonstration"
Console.WriteLine("Thank you for paying attention to my Speech Calculator Demonstration", vbCrLf, "for Mrs.McCurley's Class. I hope you get something out of my speech")
Console.WriteLine("Please choose the type of problem you want to calculate")
Console.WriteLine("-------------------------------------------------------")
Console.WriteLine("1. Addition")
Console.WriteLine("2. Subtraction")
Console.WriteLine("3. Multiplication")
Console.WriteLine("4. Division")
Console.WriteLine("5. Exit")
Console.WriteLine("-------------------------------------------------------")
If Console.ReadLine = "1" Then
Call add1()
End If
If Console.ReadLine = "2" Then
Call sub1()
End If
If Console.ReadLine = "3" Then
Call mul1()
End If
If Console.ReadLine = "4" Then
Call div1()
End If
If Console.ReadLine = "5" Then
Exit Sub
End If
End Sub
Sub again()
Console.Title = "Speech Calcualtor Demonstration"
Console.WriteLine("Thank you for paying attention to my Speech Calculator Demonstration", vbCrLf, "for Mrs.McCurley's Class. I hope you get something out of my speech")
Console.WriteLine("Please choose the type of problem you want to calculate")
Console.WriteLine("-------------------------------------------------------")
Console.WriteLine("1. Addition")
Console.WriteLine("2. Subtraction")
Console.WriteLine("3. Multiplication")
Console.WriteLine("4. Division")
Console.WriteLine("-------------------------------------------------------")
End Sub
Sub add1()
Dim number1 As Double
Dim number2 As Double
Dim result As String
Console.WriteLine("Please enter your first number")
number1 = Console.ReadLine()
Console.WriteLine("Please enter your second number")
number2 = Console.ReadLine()
result = number1 + number2
Console.WriteLine("The answer to " & number1 & "+" & number2 & "=" & result)
Console.WriteLine("Would you like to calculate another problem?")
If Console.ReadLine = "Yes" Then
Call Main()
Else
Exit Sub
End If
End Sub
Sub sub1()
Dim number1 As Double
Dim number2 As Double
Dim result As String
Console.WriteLine("Please enter your first number")
number1 = Console.ReadLine()
Console.WriteLine("Please enter your second number")
number2 = Console.ReadLine()
result = number1 - number2
Console.WriteLine("The answer to " & number1 & "-" & number2 & "=" & result)
Console.WriteLine("Would you like to calculate another problem?")
Console.ReadLine()
If Console.ReadLine = "Yes" Then
Call Main()
Else
Exit Sub
End If
End Sub
Sub mul1()
Dim number1 As Double
Dim number2 As Double
Dim result As String
Console.WriteLine("Please enter your first number")
number1 = Console.ReadLine()
Console.WriteLine("Please enter your second number")
number2 = Console.ReadLine()
result = number1 * number2
Console.WriteLine("The answer to " & number1 & "*" & number2 & "=" & result)
Console.WriteLine("Would you like to calculate another problem?")
Console.ReadLine()
If Console.ReadLine = "Yes" Then
Call Main()
Else
Exit Sub
End If
End Sub
Sub div1()
Dim number1 As Double
Dim number2 As Double
Dim result As String
Console.WriteLine("Please enter your first number")
number1 = Console.ReadLine()
Console.WriteLine("Please enter your second number")
number2 = Console.ReadLine()
result = number1 / number2
Console.WriteLine("The answer to " & number1 & "/" & number2 & "=" & result)
Console.WriteLine("Would you like to calculate another problem?")
Console.ReadLine()
If Console.ReadLine = "Yes" Then
Call Main()
Else
Exit Sub
End If
End Sub
End ModuleThe problem I am having is this. When I choose my type of problem instead of having to enter the # once I have to enter it twice before it calls the Sub. Then when I want to do another problem and I type yes, it wont go, so I keep typign yes and after 4 times it exits the program. I am so confused since I dont even have that many console.readline's in the sub's. Please help
__________________
Forgiveness is the fragrance that the violet sheds on the heal that has crushed it. - Mark Twain Destruction leads to a very rough road, but it also breeds creation. |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
I don't do .NET; that said, what do you suppose would happen if everyone that wanted to study the universe began with a call to "big bang".
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 | |
|
Hobbyist Programmer
Join Date: Oct 2005
Posts: 211
Rep Power: 3
![]() |
Quote:
-MBirchmeier |
|
|
|
|
|
|
#4 |
|
PFO Founder
![]() ![]() |
csharp Syntax (Toggle Plain Text)
After looking through your code, I couldn't figure out where the again() sub was being used. Seems like of pointless to have it there.
__________________
BIG K aka Kyle Programming Forums Kyle K Online Please do not PM or email me programming questions. Post them in the forums instead. |
|
|
|
|
|
#5 | |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Quote:
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
|
#6 |
|
Professional Programmer
|
Thanks yall
Thanks big_k, the again was at the start where Call Main is now, I looked over my code and relized agaim and Main are the same code, before I had it call again and then changed it to call Main, thkans though.
And yes Dawei, I was a bit confused at your first post, but thanks for trying to help. Maybe when I'm older I can give advice like that. lol
__________________
Forgiveness is the fragrance that the violet sheds on the heal that has crushed it. - Mark Twain Destruction leads to a very rough road, but it also breeds creation. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| The Black Art of Video Game Console Design | lostcauz | Book Reviews | 0 | Apr 26th, 2006 7:31 PM |
| problems loading 2 dlls in Delphi7 | nico765 | Delphi | 0 | Jan 7th, 2006 3:03 PM |
| console output | matko | C++ | 10 | Sep 26th, 2005 2:14 PM |
| Problems with C programming in Visual Studio .NET 2003 | debugger1 | C | 4 | Jun 3rd, 2005 7:03 AM |
| How Do I: Rewrite a Delphi 6 console app to run as a DLL for IIS5 | daemonreaver | Delphi | 0 | Mar 9th, 2005 2:05 PM |