473,387 Members | 1,925 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,387 software developers and data experts.

Populate array with user inputs

I am trying to populate two arrays. One with combo box and the other with a text input. The combo box has multiple choices of different counties people live in. The text input is for income amount of person that lives in each county. I will later need to break info into Average Household income and Number of House Holds surveyed.

Data will look like the following example:
Average Households Income
Ohio: $30,000.00
Hamilton: 40,000.00
Butler: 20,000.00
Clermont: 30,000.00
Warren: 30,000.00
Kentucky: 35,000.00
Boone: 40,000.00
Campbell: 30,000.00
Kenton: 35,000.00

I will use data loaded into array to figure average income for each state. and then total for each county.

I will also need to get the following data:
Number of HouseHolds Surveyed
Ohio: 5
Hamilton: 2
Butler: 1
Clermont: 1
Warren: 1
Kentucky: 5
Boone: 2
Campbell: 2
Kenton: 1

I will load the array with a button click, each time button is clicked input fields reset and input second set of data for array and that continues. Once I have households data entered I can click another button that will show Average Household Income and then a third button to show Number of households surveyed. I will display each in a message box when button is clicked. Right now I need help loading array. I know how to set arrays up and how to hardcode data into the array, but I have no idea how to make inputs go into an array. I have code started if you would like to see.

Thanks for any help you can give.

Option Strict On

Public Class frmSurvey

'Arrays to hold Houshold income and county
Dim intIncome() As Double 'Array for users income
Dim strCounty() As String 'Array for users county live in

Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
'Populate both arrays from user inputs

'Populating array with incomes from each person surveyed and this array works parallel to the second array strCounty()
'To match up income with person in specific county so that data can add to show total income for each county that was inputted.
For i = 0 To intIncome.Length - 1
intIncome(i) = CDbl(txtIncome.Text)
Next

'Populating array from user input from Combobox selections when submit button is clicked the form resets
'After reset another county is selected. After done with all submits I can then do counts for data totals
For i = 0 To strCounty.Length - 1
strCounty(i) = cboCountyState.Text
Next

'After both arrays are filled next figure out how many people were surveyed in each county through btnSurveyed_Click

'clear combobox and textbox for next input
txtIncome.Clear()
cboCountyState.Text = ""
End Sub

Private Sub btnSurveyed_Click(sender As Object, e As EventArgs) Handles btnSurveyed.Click
'Calculate total number of houses surveyed


Dim intCount As Integer
Dim strHamilton As String = "Hamilton, OH"

'Search for each occurance of Hamilton, OH in strCounty() array
For i = 0 To strCounty.Length - 1
If strCounty(i) = strHamilton Then
intCount += 1
End If

Next

' I have only worked on counting for Hamilton
MessageBox.Show("Number of Households Surveyed" & vbNewLine &
"Ohio: (total Ohio surveyed)" & vbNewLine &
" Hamilton: " & intCount & vbNewLine &
" Butler: " & vbNewLine &
" Clermont: " & vbNewLine &
" Warren: " & vbNewLine &
)
End Sub
Dec 6 '16 #1
0 1059

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

Similar topics

11
by: Sven Neuberg | last post by:
Hi, I have been handed the task of updating and maintaining a web application, written in ASP and Javascript, that takes complex user inputs in HTML form and submits them to server-side ASP...
10
by: jeff regoord | last post by:
A user inputs a float value. The scanf() function gets the value. However, I need to create an error handler with an if else statement saying invalid input if the input is not a number. Does...
2
by: Anil | last post by:
Hi All, I have a string which has product names, which are seperated by comma. The number of products in the string are random. I want to populate the array using the string, one product per...
1
by: Scott | last post by:
Hi, I'm using a form to collect values for later analysis. My question is, how do I validate the value the user inputs into a textbox? For example, many of the values require a real number and...
6
by: jrshack | last post by:
I have a web form that users input answers and when submitted I want the ASP code to place the user inputs into certain locations of a HTML form. The form is then automatically opened in a new...
5
Kelicula
by: Kelicula | last post by:
Hello all. I have a problem which seems to make no sense to me. Therefore I must be doing something wrong. I am trying to populate an array using split with a regexe. Here is the code (snippet...
1
by: bmbuke | last post by:
Hi everyone. This is my first time posting to this forum and I am only about 9 weeks into java programming so I am still learining a lot! My primary issue is I need to know how to fill an array...
3
by: malika | last post by:
How to create dynamically tables on the basis of user inputs in the textbox for example if user write 3 in the textbox three table should be display n so on code of table is this is my table code...
0
by: onlygoodnoiz | last post by:
Hello everyone I am struggling on this country capital problem where the user inputs a country and the country and capital are suppose to be the output. Also even if the user enters Sp for spain, all...
1
by: Luffy0114 | last post by:
Alright, so I just start self-learning for computer science over Internet, and there is a question that I don't know how to do it. Please help by giving me a hint or something. Question: Create...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.