473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Populating An Array With String Values

How can I fill an array with string values from an InputBox and then display that in a ListBox?

Expand|Select|Wrap|Line Numbers
  1. Public Class frmQuiz
  2.     Dim strQuestions(10) As String
  3. Private Sub btnQuestion2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuestion2.Click
  4.         Dim strQuestion2 As String
  5.         strQuestion2 = InputBox("What is the last name of the player who many consider to be the best player of all time?")
  6.         strQuestions(1) = strQuestion2
  7.     End Sub
  8.  Private Sub btnGradeQuiz_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGradeQuiz.Click
  9.         MessageBox.Show("Your answers will be displayed. You may make changes to your response before you submit.")
  10.         For Each Value As String In strQuestions
  11.             lstAnswers.Items.Add(strQuestions)
  12.  
  13.  
  14.         Next
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.     End Sub

This does not work right and just displays "String[] Array"
Jan 12 '17 #1
1 1192
Frinavale
9,735 Expert Mod 8TB
The ListBox.Items.Add method adds a single item to the items and you are providing a whole array. It is displaying "String[] Array" because it is calling the ToString method on the array since it is not a single string.

Provide the array to the Items property instead of using the Add method...or if you can't do that then loop through the array and add the items to the ListBox individually using the Add method.
Jan 12 '17 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: VB | last post by:
I want to return string values like below public enum PropType { All = "A", Mature = "M" }
1
by: Miguel Dias Moura | last post by:
Hello, I am working on an ASP.NET/VB web site with Microsoft SQL 2000 database. I have a page with a search form where keywords are submitted. Consider I write the the keywords 'asp' and...
1
by: Sam Clark | last post by:
The following code puts a structure location in an array field: XrefArray(i) = "ArrayIn(i).Field" & RefText.Substring(NumStart + 1) --------------------------------------------------------...
1
by: anand basha | last post by:
Hi, how to set array of values to the dropdown listbox while clicking the button *** Sent via Developersdex http://www.developersdex.com ***
2
by: kw_uh97 | last post by:
Hello everone, I am a newbie and I have a recordset that returns the values XXXXMain XXXX1 XXXX2 XXXX3 XXXX4 XXXX5 XXXX6 YYYY1
6
by: Chuck Anderson | last post by:
My knowledge of JavaScript is limited. I learn from example and then adapt those examples to suit my needs. I have stumped myself on this one. I have a form with checkboxes that I want to...
1
by: spud379 | last post by:
i am doing an assignment in vb.net. i have to select at random from and array what i have is dim country(29) as string dim random as new random txtcountry.text = random.next(country) I...
1
by: sivanandan | last post by:
Hi I Pass The 3 String Value Like "1,2,3" 2nd String "x,y,z" 3rd String "a,b,c" Spilit The Those String Values And Compare The Value"1" Into Table The Table Contain Data Only One...
4
by: Mokita | last post by:
Hello, I am working with Taverna to build a workflow. Taverna has a beanshell where I can program in java. I am having some problems in writing a script, where I want to eliminate the duplicates...
1
by: capablanca | last post by:
Hello, I just i would like to know how to record a string from a label to an array string, if anybody can show me an example, thanks. ? string stringArray = labelone.Text
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.