Find the error in this caculator code and get it work
Find the error in this caculator code and get it work
Find the error in this caculator code and get it work
Find the error in this caculator code and get it work
Find the error in this caculator code and get it work
Find the error in this caculator code and get it work Find the error in this caculator code and get it work Find the error in this caculator code and get it work Find the error in this caculator code and get it work Find the error in this caculator code and get it work Find the error in this caculator code and get it work Find the error in this caculator code and get it work Find the error in this caculator code and get it work
Find the error in this caculator code and get it work Find the error in this caculator code and get it work
Find the error in this caculator code and get it work
Go Back  Xtreme Visual Basic Talk > > > Find the error in this caculator code and get it work


Reply
 
Thread Tools Display Modes
  #1  
Old 04-20-2010, 10:16 PM
Swordtech17 Swordtech17 is offline
Newcomer
 
Join Date: Apr 2010
Posts: 1
Question Find the error in this caculator code and get it work


Code:
Public Class Form1
    Dim numlist(50) As String
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
        Dim Maxium, count As Double
        Dim California, Hotel As String
        Dim NumPlace As Integer
        Dim Position As Integer = 1
        Dim Proccesser As Integer = 1
        num = " "
        maxium = txtIn.Text.Length - 1
        For count = 0 To maxium
            symbol = txtIn.Text.Substring(CInt(count), 1)

            If California = "+" Or California = "-" Or California = "/" Or California = "*" Then
                numlist(position) = num
                numlist(CInt(position)) = symbol
                Hotel = " "
                numplace += 2
                position += 2
            Else
                Hotel = (Hotel & California)

            End If
        Next count
        numlist(NumPlace) = num

        For count = 0 To numposition

            lstDbg.Items.Add(count & numlist(CInt(count)))

        Next count
        numlist(NumPlace) = num
        For count = 0 To numposition
            lstDbg.Items.Add(count & numlist(CInt(count)))

        Next count
        Dim count2 = 0
        Dim count3 = 0
        count2 = (MultiplyDivide())
        count3 = (AddSubtract())
        While ((count2 < 50) And (MultiplyDivide() > 0))
            For count = 0 To NumPlace
                lstDbg.Items.Add(count & "      " & numlist(CInt(count)))
            Next count
            count2 += 1
            lstDbg.Items.Add("count2 = " & count2)
        End While

        While (((count3 < 50) And (AddSubtract() > 0)))
            For count = 0 To NumPlace
                lstDbg.Items.Add(count & "    " & numlist(CInt(count)))

            Next
            count3 += 1
            lstDbg.Items.Add("count3 = " & count3)

        End While
    End Sub



    Function MultiplyDivide() As Integer
        Dim Position As Integer
        Dim H = 0
        Dim Mock1 = 0
        Dim Results As Integer
        Position = 1
        Results = CInt(numlist(0))
        For H = 0 To 10
            lstDbg.Items.Add(H & "  -   " & numlist(H))
        Next
        H = 0
        Do While (Mock1 = 0) And (H < 20) And (CBool(numlist(Position) <> "="))
            H = H + 1
            lstDbg.Items.Add("Place" & Position)
            lstDbg.Items.Add(numlist(Position))
            If (numlist(Position) = "*") Then
                Results = CInt(CStr(CDbl(numlist(Position - 1))) * CDbl(numlist(Position + 1)))
                Mock1 = 1
            ElseIf (numlist(Position) = "/") Then
                Results = CInt(CStr(CDbl(numlist(Position - 1))) / CDbl(numlist(Position + 1)))
                Mock1 = 1
            End If
            Position += 2
        Loop
        numlist(Position - 3) = CStr(Results)
        While (CBool(numlist(Position) <> "="))
            numlist(Position - 2) = numlist(Position)
            Position = Position + 1



        End While
        numlist(Position - 2) = "="
        If (Position - 2) = 1 Then Mock1 = 0
        lstDbg.Items.Clear()
        lstDbg.Items.Add("Results = " & Results & " Mock = " & Mock1)

        Return Mock1








    End Function
    Function AddSubtract() As Integer
        Dim Position As Integer
        Dim H = 0
        Dim Mock2 = 0
        Dim Results As Integer
        Position = 1
        Results = CInt(numlist(0))
        For H = 0 To 10
            lstDbg.Items.Add(H & " - " & numlist(H))
        Next
        H = 0
        Do While (Mock2 = 0) And (H < 20) And (CBool(numlist(Position) <> "="))
            H = H + 1
            If (numlist(Position) = "+") Then
                Results = CInt(CStr(CDbl(numlist(Position - 1)) + CDbl(numlist(Position + 1))))
                Mock2 = 1
            ElseIf (numlist(Position) = "-") Then
                Results = CInt(CStr(CDbl(numlist(Position - 1)) - CDbl(numlist(Position + 1))))
                Mock2 = 1

            End If
            Position += 2
        Loop
        numlist(Position - 3) = CStr(Results)
        While (CBool(numlist(Position) <> "="))
            numlist(Position - 2) = numlist(Position)
            Position = Position + 1
        End While
        numlist(Position - 2) = "="
        If (Position - 2) = 1 Then Mock2 = 0
        lstDbg.Items.Clear()
        lstDbg.Items.Add("Results = " & Results & "  Mock = " & Mock2)
        Return Mock2
    End Function
End Class

Last edited by Flyguy; 04-21-2010 at 08:53 AM. Reason: Added [code]..[/code] tags
Reply With Quote
  #2  
Old 04-21-2010, 06:17 AM
PlausiblyDamp's Avatar
PlausiblyDampFind the error in this caculator code and get it work PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

You really should include the code in the [ code ] [ /code ] tags (just remove the spaces) to make things easier to read.

Then again you shouldn't expect people to just dive in and try to debug code without even a clue as to what it should be doing, what the expected results are or where it is going wrong. If you want people to help then you really need to provide more information than an unexplained lump of code.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 04-21-2010, 07:06 AM
CrashPilot CrashPilot is offline
Regular
 
Join Date: Jun 2009
Location: Netherlands
Posts: 73
Default

Hi, as PlausiblyDamp noted please take some time to format the code with [CODE] Tags and indents. Its hard to read like this. And definitly try to explain what the error is, what your results are and what the result should be or this will be searching for a needle in a heystack :P. Unless this was mean as a puzzle ofc.
Reply With Quote
Reply


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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Find the error in this caculator code and get it work
Find the error in this caculator code and get it work
Find the error in this caculator code and get it work Find the error in this caculator code and get it work
Find the error in this caculator code and get it work
Find the error in this caculator code and get it work
Find the error in this caculator code and get it work Find the error in this caculator code and get it work Find the error in this caculator code and get it work Find the error in this caculator code and get it work Find the error in this caculator code and get it work Find the error in this caculator code and get it work Find the error in this caculator code and get it work
Find the error in this caculator code and get it work
Find the error in this caculator code and get it work
 
Find the error in this caculator code and get it work
Find the error in this caculator code and get it work
 
-->