+ Reply to Thread
Results 1 to 6 of 6

VBA Looping code help need for Multiplication Table in UserForm

  1. #1
    Forum Contributor
    Join Date
    10-30-2011
    Location
    Doha
    MS-Off Ver
    MS office 365
    Posts
    701

    Question VBA Looping code help need for Multiplication Table in UserForm

    Hi Folks,

    I have a workbook with a userform and I have added some codes also to show the Multiplication Table of textbox1 value (for 1 to 10). The entered code returns only one multiplication result, e.g. If I entered “2” in the textbox1 I am getting the result 2 x 10 = 20 but I want to show 1 x 2 = 2, 2 x 2 = 4, 3 x 2 = 6...till 10 x 2 = 20. I am unable to build the looping code. I have attached a file of what I'm trying to accomplish. Thanks in advance for your expertise!

    Joshi
    Attached Files Attached Files
    Last edited by krjoshi; 12-24-2011 at 01:30 PM.

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: VBA Looping code help need for Multiplication Table in UserForm

    Hi,

    The problem is that you keep replacing the Label1.Caption with the new one. Replace your current form code with this one:

    Please Login or Register  to view this content.
    Also you will notice that I now declared each variable separately. In VBA if you only put the declaration at the end of the group then you are only declaring the last variable while the rest are being defaulted to Variants. Therefore:

    Please Login or Register  to view this content.
    is not the same as

    Please Login or Register  to view this content.
    Hope this helps.

    abousetta
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  3. #3
    Forum Contributor
    Join Date
    10-30-2011
    Location
    Doha
    MS-Off Ver
    MS office 365
    Posts
    701

    Re: VBA Looping code help need for Multiplication Table in UserForm

    Hi Abousetta,

    Its working Well!. For what purpose you entered " Chr(10) ", Can you please explain?.

    Thank you so much

    Joshi

  4. #4
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: VBA Looping code help need for Multiplication Table in UserForm

    Hi Joshi,

    Chr(10) is a paragraph break. Without it (or something similar) the results would be all in one line and almost impossible to read.

    Hope this helps.

    If you are satisfied with the responses, then please mark the thread as Solved.

    Good luck.

    abousetta

  5. #5
    Forum Contributor
    Join Date
    10-30-2011
    Location
    Doha
    MS-Off Ver
    MS office 365
    Posts
    701

    Re: VBA Looping code help need for Multiplication Table in UserForm

    Thank you so much

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,164

    Re: VBA Looping code help need for Multiplication Table in UserForm

    Hi,

    In VBA there are some Global Constants or Intrinsic Constants that are very common. The carriage return and linefeed characters are so common they have visual basic names.

    vbCr and vbLf and even vbCrLf are available if you don't want to use the Chr(10) type of notation. See http://support.microsoft.com/kb/211774
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1