I need to create an array of decimals by getting input from the user. I know how to create one of random numbers but do not know how to get the input from a user through a text box to a list box.

Do you mean a string like "......"? Or do you mean a series of decimal numbers? I presume you know how to create a textbox control. Let's say you have one namex txtDecimals. You can refer to the text in the box by txtDecimals.Text. For example, to copy it to a local variable you do

Dim mystring As String

mystring = txtDecimals.Text

If, however, the user has entered the number of decimals they want then you get that number by converting the text in the control to an integer value via CInt as follows:

Dim numdecimals as Integer

numdecimals = CInt(txtDecimals.Text)

Keep in mind that if the user has entered a string that cannot be converted to a number you will get an error. You can account for this by using IsNumeric to check the string before converting, or by doing the conversion in a Try/Catch block.

If the user has entered text like "12 5123 17 947 42" then you have to parse the text using Split and converting each item in the resulting array.

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.