Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6238001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:08:01+00:00 2026-05-24T11:08:01+00:00

I need help here in a multiplication table program. The program asks the user

  • 0

I need help here in a multiplication table program. The program asks the user through a text box the dimension of the two-dimensional array. When the dimension is retrieved, the program should print the multiplication table with the given dimension neatly in the form. The problem is, I do not know how to print the array neatly in a table format. It’s something like this as a sample output:

1 2  3  4  5 
2 4  6  8  10
3 6  9  12 15
4 8  12 16 20
5 10 15 20 25

Here’s my work.

Option Explicit

Dim maxNum As Integer
Dim multiplicationTable() As Integer
Dim x As Integer
Dim y As Integer

Private Sub cmdDisplay_Click()

    cmdDisplay.Enabled = False
    maxNum = Val(txtDimension.Text)

    ReDim multiplicationTable(maxNum, maxNum) As Integer

    For y = 1 To maxNum
        For x = 1 To maxNum
            multiplicationTable(x, y) = x * y
        Next x
    Next y

End Sub

What piece of code could make this program print the table neatly in the form?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:08:02+00:00Added an answer on May 24, 2026 at 11:08 am

    This will print the table exactly as you show in your “neat” example. The width of each column is equal to the maximum number of digits in that column (plus one space delimiter). Some may think it would look neater with a uniform column width (=maximum number of digits in entire table) and the code could easily be modified to do this.

    ' Convert integer table to string table
    Dim astrTable() As String
    ReDim astrTable(1 To UBound(multiplicationTable, 1), _
        1 To UBound(multiplicationTable, 2))
    Dim intMaxDigitsInColumn As Integer
    Dim intDigitsInThisNumber As Integer
    For y = 1 To maxNum
        ' Determine width of column (= max number of digits)
        intMaxDigitsInColumn = 1
        For x = 1 To maxNum
            intDigitsInThisNumber = 1 + _
                Int(Log(multiplicationTable(x, y)) / Log(10#))
            If intDigitsInThisNumber > intMaxDigitsInColumn Then
                intMaxDigitsInColumn = intDigitsInThisNumber
            End If
        Next x
    
        ' Convert each table element into string of appropriate length
        For x = 1 To maxNum
            astrTable(x, y) = Space(intDigitsInThisNumber)
            Mid(astrTable(x, y), 1) = CStr(multiplicationTable(x, y))
        Next x
    Next y
    
    ' Print the table with a space delimiter between columns
    Dim strTable As String
    strTable = ""
    For x = 1 To maxNum
        For y = 1 To maxNum
            strTable = strTable & astrTable(x, y) & " "
        Next y
        strTable = strTable & vbCrLf
    Next x
    Debug.Print strTable
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help here in my practice program. I have a json array: myData=[{plank_number:1,thickness:5,width:7,length_t:8,quantity:1},
$('tr').find(need help here).parent().css('backgroundColor', '#fcc'); Would like to perform inequality check of two dates (both
I need some help here. I have a mysql table called dictionary like this:
i need some help here. I have a dialog box that contains an iFrame
First of all I am in DESPERATE need of help here PLEASE I will
BeautifulSoup newbe... Need help Here is the code sample... from mechanize import Browser from
I am very new to mysql and databases, so I need help here... How
I need help parsing out some text from a page with lxml. I tried
Need help understanding what I am doing with the syntax here, please help! I
I need help, I am trying to make use of Lattice Multiplication in java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.