Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 22nd, 2006, 11:21 AM   #1
bigguy
Professional Programmer
 
bigguy's Avatar
 
Join Date: Sep 2005
Location: Arkansas
Posts: 298
Rep Power: 0 bigguy is an unknown quantity at this point
Send a message via AIM to bigguy Send a message via MSN to bigguy Send a message via Yahoo to bigguy
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 Module

The 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.
bigguy is offline   Reply With Quote
Old Sep 22nd, 2006, 11:32 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Sep 22nd, 2006, 11:49 AM   #3
MBirchmeier
Hobbyist Programmer
 
Join Date: Oct 2005
Posts: 211
Rep Power: 4 MBirchmeier is on a distinguished road
Quote:
Originally Posted by DaWei View Post
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".
It seems like you have a habit of leaving your pearls of wisdom buried in the mud, one might not always be able to see what you're talking about, but once one gets their hands sufficiently dirty it is easy enough to find.

-MBirchmeier
MBirchmeier is offline   Reply With Quote
Old Sep 22nd, 2006, 12:43 PM   #4
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,667
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
csharp Syntax (Toggle Plain Text)
  1. Module Module1
  2.  
  3. Sub Main()
  4. Console.Title = "Speech Calculator Demonstration"
  5. 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")
  6. Console.WriteLine("Please choose the type of problem you want to calculate")
  7. Console.WriteLine("-------------------------------------------------------")
  8. Console.WriteLine("1. Addition")
  9. Console.WriteLine("2. Subtraction")
  10. Console.WriteLine("3. Multiplication")
  11. Console.WriteLine("4. Division")
  12. Console.WriteLine("5. Exit")
  13. Console.WriteLine("-------------------------------------------------------")
  14. Dim choice As String
  15. choice = Console.ReadLine()
  16. If choice = "1" Then
  17. Call add1()
  18. ElseIf choice = "2" Then
  19. Call sub1()
  20. ElseIf choice = "3" Then
  21. Call mul1()
  22. ElseIf choice = "4" Then
  23. Call div1()
  24. ElseIf choice = "5" Then
  25. Exit Sub
  26. End If
  27. End Sub
  28.  
  29. Sub again()
  30. Console.Title = "Speech Calcualtor Demonstration"
  31. 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")
  32. Console.WriteLine("Please choose the type of problem you want to calculate")
  33. Console.WriteLine("-------------------------------------------------------")
  34. Console.WriteLine("1. Addition")
  35. Console.WriteLine("2. Subtraction")
  36. Console.WriteLine("3. Multiplication")
  37. Console.WriteLine("4. Division")
  38. Console.WriteLine("-------------------------------------------------------")
  39. End Sub
  40.  
  41. Sub add1()
  42. Dim number1 As Double
  43. Dim number2 As Double
  44. Dim result As String
  45. Console.WriteLine("Please enter your first number")
  46. number1 = Console.ReadLine()
  47. Console.WriteLine("Please enter your second number")
  48. number2 = Console.ReadLine()
  49. result = number1 + number2
  50. Console.WriteLine("The answer to " & number1 & "+" & number2 & "=" & result)
  51. Console.WriteLine("Would you like to calculate another problem?")
  52. Dim choice As String
  53. choice = Console.ReadLine()
  54. If choice = "Yes" Then
  55. Call Main()
  56. Else
  57. Exit Sub
  58. End If
  59. End Sub
  60.  
  61. Sub sub1()
  62. Dim number1 As Double
  63. Dim number2 As Double
  64. Dim result As String
  65. Console.WriteLine("Please enter your first number")
  66. number1 = Console.ReadLine()
  67. Console.WriteLine("Please enter your second number")
  68. number2 = Console.ReadLine()
  69. result = number1 - number2
  70. Console.WriteLine("The answer to " & number1 & "-" & number2 & "=" & result)
  71. Console.WriteLine("Would you like to calculate another problem?")
  72. Dim choice As String
  73. choice = Console.ReadLine()
  74. If choice = "Yes" Then
  75. Call Main()
  76. Else
  77. Exit Sub
  78. End If
  79. End Sub
  80.  
  81. Sub mul1()
  82. Dim number1 As Double
  83. Dim number2 As Double
  84. Dim result As String
  85. Console.WriteLine("Please enter your first number")
  86. number1 = Console.ReadLine()
  87. Console.WriteLine("Please enter your second number")
  88. number2 = Console.ReadLine()
  89. result = number1 * number2
  90. Console.WriteLine("The answer to " & number1 & "*" & number2 & "=" & result)
  91. Console.WriteLine("Would you like to calculate another problem?")
  92. Dim choice As String
  93. choice = Console.ReadLine()
  94. If choice = "Yes" Then
  95. Call Main()
  96. Else
  97. Exit Sub
  98. End If
  99. End Sub
  100.  
  101. Sub div1()
  102. Dim number1 As Double
  103. Dim number2 As Double
  104. Dim result As String
  105. Console.WriteLine("Please enter your first number")
  106. number1 = Console.ReadLine()
  107. Console.WriteLine("Please enter your second number")
  108. number2 = Console.ReadLine()
  109. result = number1 / number2
  110. Console.WriteLine("The answer to " & number1 & "/" & number2 & "=" & result)
  111. Console.WriteLine("Would you like to calculate another problem?")
  112. Dim choice As String
  113. choice = Console.ReadLine()
  114. If choice = "Yes" Then
  115. Call Main()
  116. Else
  117. Exit Sub
  118. End If
  119. End Sub
  120.  
  121. End Module
Above is the way I took your code and changed it. What I ended up doing is removing all the console.readline's you had inside of the if statements and put one before the if and and put the input into a variable instead and then checking the variable in the if. After testing it. It looks like it worked fine.

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.
big_k105 is offline   Reply With Quote
Old Sep 22nd, 2006, 3:36 PM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
have a habit of leaving your pearls of wisdom buried in the mud
Sometimes I do. Sometimes I submit full-blown copy-and-paste solutions or long-drawn-out explications and discussions. Feed a man a fish, he'll eat for a day. Point him to the way out of the cave-in, and dirty fingernails or not, he prolly won't be digging under shaky cutbanks again.
__________________
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
DaWei is offline   Reply With Quote
Old Sep 24th, 2006, 12:34 PM   #6
bigguy
Professional Programmer
 
bigguy's Avatar
 
Join Date: Sep 2005
Location: Arkansas
Posts: 298
Rep Power: 0 bigguy is an unknown quantity at this point
Send a message via AIM to bigguy Send a message via MSN to bigguy Send a message via Yahoo to bigguy
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.
bigguy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
The Black Art of Video Game Console Design lostcauz Book Reviews 0 Apr 26th, 2006 8:31 PM
problems loading 2 dlls in Delphi7 nico765 Delphi 0 Jan 7th, 2006 4:03 PM
console output matko C++ 10 Sep 26th, 2005 3:14 PM
Problems with C programming in Visual Studio .NET 2003 debugger1 C 4 Jun 3rd, 2005 8:03 AM
How Do I: Rewrite a Delphi 6 console app to run as a DLL for IIS5 daemonreaver Delphi 0 Mar 9th, 2005 3:05 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:18 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC