![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Mar 2008
Posts: 35
Rep Power: 0
![]() |
Array
hi there.... how are you guys??
could somebody help to correct my code??? i have a problem for displaying arrays in the list box here is the code Public Class Form1
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
ErrorProvider1.Clear()
Dim total As Decimal
Dim sales As Decimal
Dim flag As Boolean
flag = False
sales = Val(txtSales.Text)
total = 200 + (0.09 * sales)
txtSalary.Text = total.ToString
If (txtSales.Text = "") Then
ErrorProvider1.SetError(txtSales, "You shoulde enter the sales")
flag = True
txtSalary.Text = ""
End If
End Sub
Private Sub btnTotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTotal.Click
Dim salary As Integer
Dim survey(0 To 8) As Integer
ListBox1.Items.Add("Salary Range:" + " " + "Total:")
ListBox1.Items.Add(salary.ToString)
Select Case salary
Case 200 To 299
survey(0) += 1
Case 300 To 399
survey(1) += 1
Case 400 To 499
survey(2) += 1
Case 500 To 599
survey(3) += 1
Case 600 To 699
survey(4) += 1
Case 700 To 799
survey(5) += 1
Case 800 To 899
survey(6) += 1
Case 900 To 999
survey(7) += 1
Case Is > 100
survey(8) += 1
End Select
End Sub
End Classand this is what it shows ![]() how can i display all of them?? |
|
|
|
|
|
#2 |
|
Professional Programmer
|
Re: Array
Show all of what, currently you are displaying salery which has only been declared not even had a value assigned to it. Maybe i missed what you are asking.
Chris
__________________
Steven Skiena - Algorithms ,[->+>+<<]>>[-<<+>>]>++++++++[-<++++++++>]<+[-<->]>+<<[[-]+++++++++++++++.[-]>]>>[+++++++++.[-]],brainf**k -- It's such a pretty language |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Mar 2008
Posts: 35
Rep Power: 0
![]() |
Re: Array
i want to display
Select Case salary
Case 200 To 299
survey(0) += 1
Case 300 To 399
survey(1) += 1
Case 400 To 499
survey(2) += 1
Case 500 To 599
survey(3) += 1
Case 600 To 699
survey(4) += 1
Case 700 To 799
survey(5) += 1
Case 800 To 899
survey(6) += 1
Case 900 To 999
survey(7) += 1
Case Is > 100
survey(8) += 1
End Select |
|
|
|
|
|
#4 |
|
Professional Programmer
|
Re: Array
The reason why you are getting a 0 and that is it, is because the only item you are adding to ur list box after the first line is the value of salary.
VB.NET Syntax (Toggle Plain Text)
if you are looking to print out the value in wach of the survey items from 0-8 then you would need to do something like this, after you case statement. All the case statement is doing is checking the value of salary and then increment the correct item with the array survey. Not adding them to the list box. Something like this would add all of the items from survey into the listbox. VB.NET Syntax (Toggle Plain Text)
Cheers, Chris
__________________
Steven Skiena - Algorithms ,[->+>+<<]>>[-<<+>>]>++++++++[-<++++++++>]<+[-<->]>+<<[[-]+++++++++++++++.[-]>]>>[+++++++++.[-]],brainf**k -- It's such a pretty language |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Mar 2008
Posts: 35
Rep Power: 0
![]() |
Re: Array
i will try it
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Array Sorting | grimpirate | Software Design and Algorithms | 18 | Jan 24th, 2008 9:04 PM |
| dynamic array help | quickster12 | C++ | 4 | Nov 29th, 2007 11:52 PM |
| problem processing file into a char array | csrocker101 | C++ | 1 | May 8th, 2007 11:50 PM |
| changing size of an array | Eric the Red | Java | 3 | Apr 3rd, 2006 8:19 PM |
| Installing IPB 2.03 | bh4575 | Other Web Development Languages | 0 | Apr 23rd, 2005 2:36 AM |