Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 23rd, 2008, 11:36 AM   #1
A.K.Al Shamsi
Programmer
 
A.K.Al Shamsi's Avatar
 
Join Date: Mar 2008
Posts: 35
Rep Power: 0 A.K.Al Shamsi is on a distinguished road
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 Class


and this is what it shows




how can i display all of them??
A.K.Al Shamsi is offline   Reply With Quote
Old Apr 23rd, 2008, 1:15 PM   #2
Freaky Chris
Hobbyist Programmer
 
Freaky Chris's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 169
Rep Power: 1 Freaky Chris is on a distinguished road
Send a message via MSN to Freaky Chris
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
__________________
Who said i couldn't program
sarcasm = raw_input('Type in a sarcastic remark: ')
print sarcasm
Freaky Chris is online now   Reply With Quote
Old Apr 23rd, 2008, 9:30 PM   #3
A.K.Al Shamsi
Programmer
 
A.K.Al Shamsi's Avatar
 
Join Date: Mar 2008
Posts: 35
Rep Power: 0 A.K.Al Shamsi is on a distinguished road
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
all these in listbox i got 0 which is not waht i want
A.K.Al Shamsi is offline   Reply With Quote
Old Apr 24th, 2008, 1:40 AM   #4
Freaky Chris
Hobbyist Programmer
 
Freaky Chris's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 169
Rep Power: 1 Freaky Chris is on a distinguished road
Send a message via MSN to Freaky Chris
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)
  1. ListBox1.Items.Add(salary.ToString)

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)
  1. For i = 0 To 8
  2. ListBox1.Items.Add(survey(i).ToString)
  3. Next i


Cheers,
Chris
__________________
Who said i couldn't program
sarcasm = raw_input('Type in a sarcastic remark: ')
print sarcasm
Freaky Chris is online now   Reply With Quote
Old Apr 24th, 2008, 4:11 AM   #5
A.K.Al Shamsi
Programmer
 
A.K.Al Shamsi's Avatar
 
Join Date: Mar 2008
Posts: 35
Rep Power: 0 A.K.Al Shamsi is on a distinguished road
Re: Array

i will try it
A.K.Al Shamsi is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:04 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC