-
Visual Basic - Help displaying multiple items
This is my Code, and i have been trying to make thebutton so that it will automatically show everything from Mercury venus and etc and i have make it so that it show Mercury - Pluto in seperate lines but than i am not able to make it to show the name instead it only show String[]Array in every line any ideas how to fix it so that instead of string[]Array it will show each name correctly. Below is the picture attached as an example of how thefinal result will look like
Code:
Public Class Form1
Private Sub btnShow_Click(sender As Object, e As EventArgs) Handles btnShow.Click
'Number of planets before Pluto was "let go"
Const intNUM_PLANETS As Integer = 9
'Planet names
Dim strArrayPlanetNames() As String =
{"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"}
'diameter of each planet in miles
Dim dblArrayPlanetSizes() As Double =
{3031, 7521, 7926, 4223, 88846, 74898, 31763, 30800, 1430}
strArrayPlanetNames = {"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"}
For intX = 0 To intNUM_PLANETS - 1
'output name and size
lstPlanets.Items.Add(strArrayPlanetNames)
'output bar chart on next line
Next
End Sub
End Class
Screenshot after button clicked.png
Last edited by Hack; 08-21-2013 at 08:29 AM.
Reason: Added Code Tags
-
As your question deals with VB.NET rather than VB Classic I have moved your thread to the .NET forum section.
-
Comments:
Code:
'Planet names
Dim strArrayPlanetNames() As String =
{"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"}
'
'Don't need this--> strArrayPlanetNames = {"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"}
'
For intX = 0 To intNUM_PLANETS - 1
'output name and size
' --> lstPlanets.Items.Add(strArrayPlanetNames) '<-- here you were showing the entire array, 9 times
lstPlanets.Items.Add(strArrayPlanetNames(intX)) '<-- just show each array element
'output bar chart on next line
Next
Final Version:
Code:
Public Class Form1
Private Sub btnShow_Click(sender As Object, e As EventArgs) Handles btnShow.Click
'Number of planets before Pluto was "let go"
Const intNUM_PLANETS As Integer = 9
'Planet names
Dim strArrayPlanetNames() As String =
{"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"}
'diameter of each planet in miles
Dim dblArrayPlanetSizes() As Double =
{3031, 7521, 7926, 4223, 88846, 74898, 31763, 30800, 1430}
For intX = 0 To intNUM_PLANETS - 1
'output name and size
lstPlanets.Items.Add(strArrayPlanetNames(intX))
'output bar chart on next line
Next
End Sub
End Class
Similar Threads
-
By LudwigNel in forum .NET
Replies: 1
Last Post: 09-18-2008, 07:34 AM
-
By gskrishnan in forum .NET
Replies: 3
Last Post: 11-09-2007, 06:32 AM
-
By ulm_quest in forum .NET
Replies: 2
Last Post: 12-11-2006, 10:56 AM
-
By Tim Romano in forum .NET
Replies: 3
Last Post: 03-02-2001, 03:06 AM
-
By computerdude7 in forum Web
Replies: 1
Last Post: 01-23-2001, 02:47 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|