could anyone please help me with this1. Create a simple Times Table program which will allow the user to enter an integer value n (between 1 and 20) into a textbox. On the click of a button output to a label the n times tables. Use a For…Next loop to perform the repetition.

i can output them to a list box but only last one to a label ive been stuck for 3 days any help would be much appreciated

Recommended Answers

All 2 Replies

I have a solution here, but this sounds like homework. Post your code and we'll see if we can tell you where you could improve it.

---VB.NET---

Have you thought about using an empty placeholder in your aspx page, and then populating it dynamically when the user presses the button?

What you need is this:

in your aspx:

<asp:Placeholder runat="server" id="phTimesTable"></Placeholder>

(this will be in effect an empty box, but the placeholder by its own nature can contain a collection of controls - which you can manage through code).

Then in your code behind attached to the button:

for i=1 to 12
   Dim strPrintOnScreen as String = i & " x " & me.tbUserInput.Text &  " = " & i * me.tbUserInput.Text 
   Me.phTimesTable.Controls.Add(New LiteralControl("<p>" & strPrintOnScreen & "</p>")
   Next

(You may want to validate that the input is a valid number or the multiplication will crash).
This way you add a <p></p> for each entry, but you can use the add(New literalcontrol) to add any valid html.

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.