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 8007489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:50:35+00:00 2026-06-04T17:50:35+00:00

I have a textbox called txtBox1, a second textbox called txtbox2, a Label and

  • 0

I have a textbox called txtBox1, a second textbox called txtbox2, a Label and a Button. I need to create a function that

  1. accepts 2 integer parameters and returns a string.
  2. creates a 2 dimensional array based on the integers passed in those parameters. The first integer parameter will represent txtbox1, the second integer parameter will represent txtbox2.
  3. use nested for loops to fill the array elements with incrementing values starting at 1
  4. As part of your looping structure, keep track of all element values in a string variable and separate them with a comma. For example, if the user enters 3 in txtbox1 and 5 in txtbox2 and clicks the button, we would get an array like so:

    :Length=15
    (0,0): 1    
    (0,1): 2
    (0,2): 3
    (0,3): 4
    (0,4): 5
    (1,0): 6
    (1,1): 7
    (1,2): 8
    (1,3): 9
    (1,4): 10 
    (2,0): 11
    (2,1): 12
    (2,2): 13
    (2,3): 14
    (2,4): 15    
    

    And the values populated in the elements would be 1,2,3,4,5,6,7,8,9,10,11,12,13,14 and 15.

  5. The string passed back will be in the format “array is 3 x 5 and the values in the array elements are 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15”.
  6. Populate the Label with this string value.

Here is what I have so far…

Shared Function myArray(int1 As Integer, int2 As Integer) As String

    Dim Array(int1 - 1, int2 - 1) As Integer
    Dim i As Integer
    Dim j As Integer
    Dim counter As Integer = 1

    For i = 0 To int1 - 1
        For j = 0 To int2 - 1
            Array(i, j) = counter
            counter += 1
        Next
    Next

    Return Array(i, j)

End Function
  • 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-06-04T17:50:37+00:00Added an answer on June 4, 2026 at 5:50 pm

    Ok, so you almost had it. I am assuming you are stuck on only #4. And please excuse me if I type the incorrect syntax, I have not done VB in a LONG time and I am doing this from memory.

    let’s take a look at what you had:

    For i as integer = 0 To int1 - 1
        For j as integer = 0 To int2 - 1
            Array(i, j) = counter
            counter += 1
    

    Here you are using counter to populate the array with incremental values. You can just use this variable in another string variable, and just add commas between them:

    first: add a string variable to the top:

    Dim Array(int1 - 1, int2 - 1) As Integer
    Dim i As Integer
    Dim j As Integer
    Dim counter As Integer = 1
    Dim output as String = nothing
    

    Then, use that variable in your loop:

    For i = 0 To int1 - 1
        For j = 0 To int2 - 1
            Array(i, j) = counter
            output += "" & counter & ", "
            counter += 1
        Next
    Next
    

    last, change your return to send output instead of an element in your array

    return output
    

    If you want to format the string so that the last “, ” is not shown, look at the Strings.Left function. It would go something like this:

    output = Left(output, Len(output) - 2) 'I am not sure if this is a 2 or 3, run and test
    

    Ok, hope that helps. Feel free to ask for clarification or something.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following jquery that adds a textbox when the function is called.
I have a textbox called names that allows a user to enter individual words,
I have got a textbox on a form with a method being called from
I have created a UserControl called AutorControl with a method to clear its textbox:
I have TextBox (multiline) and Label in an UpdatePanel which I refresh with javascript
I have a TextBox that user can enter search-term in it. Its bind to
I have many TextBOX in asp.net which accepts the value from user and stores
I have two textbox called BIRTH & EMAIL , and I must test in
I have a form with a textbox called 'tbWO.' This field is used to
I have usercontrol called as 'DateControl1' in which i have textbox and a calenderextender(ajax).I

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.