A teacher wants the program to:
show a visual representation of a multiplication
ask the child to key in an answer

E.G
3 x 4

What is the answer?

This is as far as I can go

Please help. I can't go horizontal. I only go vertical

Module Module1

    Sub Main()
        Dim a, b As Integer
        Dim star As String = "*"

        Dim rand As New Random
        a = rand.Next(1, 10)
        b = rand.Next(1, 10)

        Console.WriteLine(a & " X " & b)
        Dim sum As Double = a * b

        Dim i, x As Integer

        If a > b Then
            i = b
        Else
            i = a
        End If
        For x = 1 To i
            Console.Write(star)
            Console.WriteLine(star)
        Next
        Console.WriteLine()
        Console.WriteLine(sum)
        Console.ReadKey()
    End Sub

End Module
  1. Why are you calling the multiplication result sum?
  2. Why are you storing an integer result in a Double?
  3. Why aren't you reading the user response from the console?
  4. Why are you comparing a and b?

Use the StrDup method instead of using a loop.

PS. Code Snippet is to be used only for working (debugged), commented, and documented code.

I used the following code to correct my issue.

Sub Main()
    'Initialize variables
    Dim first As New Random
    Dim second As New Random
    Dim num1 = first.Next(1, 10)
    Dim num2 = second.Next(1, 10)
    Dim c As Char = "*"
    'Output Random numbers
    Console.WriteLine(num1 & " x " & num2)
    For index = 1 To num2
        Console.WriteLine(StrDup(num1, c))
    Next
    'Display question and request answer
    Console.WriteLine("what is the answer: ____")
    Dim guess As Integer = Console.ReadLine()
    Dim answer As Integer = num1 * num2
    'Set Conditions 
    If guess = answer Then
        Console.WriteLine("Congradulations!!!")
    Else
        Console.WriteLine("Wrong Answer")
        Console.WriteLine("The answer is " & answer)
    End If
    'Halt program
    Console.ReadKey()
End Sub

This is what I was looking for.
It is not perfect but it meets my minimum requirements

Thank you

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.