Have a program I am writing for class using the pseudocode given. I have written it in a flowchart program successfully, but cannot get it to work properly in VB. It is supposed to show the C for Celsius and F for Fahrenheit, and list the matching equivalents below up to 100 for Celsius when the loop will end. It shows the C and F in but no numbers...I am stumped. I have attached the zipped file. Thanks!

It's best to post your code, as some people don't want to download unknown files to their computer.

Your original code:

Module Module1
    Sub Main()
        'Declarations
        Dim intC As Integer = 0
        Dim intF As Integer = 0
        'Display 
        Console.WriteLine("C                 F")
        Console.Read()

        Do
            If intC > 100 Then
                intF = CInt((9 / 5 * intC + 32))
                Console.WriteLine(intC & "           " & intF)
                intC = intC + 10
            End If
        Loop Until (intC > 100)
    End Sub
End Module

Issues:

You have If intC > 100. This will never occur, because all of your calculations are inside the if statement and intC is 0. This if statement is unnecessary because the loop condition will do everything you need. If you choose to keep it, change it to If intC < 100. Right now you have an infinite loop, because "intC" is always < 100.

You have Console.Read before the loop. This will wait for input. You may want to put this after the loop, if your intent is to keep the window open until the user presses a key.

Note: You can use "Console.WriteLine" statements to help you debug your program. See below for example.

This is your original code with "Console.WriteLine" statements inserted for debugging purposes:

Module Module1
    Sub Main()
        'Declarations
        Dim intC As Integer = 0
        Dim intF As Integer = 0
        'Display 
        Console.WriteLine("C                 F")

        'used for debugging
        Console.WriteLine("Before console.read")

        Console.Read()

        Do
            'used for debugging
            Console.WriteLine("in loop. before if. intC=" & intC)

            If intC > 100 Then
                'used for debugging
                Console.WriteLine("in if. intC=" & intC)

                intF = CInt((9 / 5 * intC + 32))
                Console.WriteLine(intC & "           " & intF)
                intC = intC + 10
            End If

            'used for debugging
            Console.WriteLine("after if. intC=" & intC)

        Loop Until (intC > 100)
    End Sub
End Module

Thanks CGeier, I will try it in the morning. It is completely different writing it in VB than in Raptor(the flowchart program we have to use as well.) I'll keep you updated! Thanks again. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.