| | |
storing values in arrays fom inputbox?
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2008
Posts: 14
Reputation:
Solved Threads: 0
i have declared an array which i want to populate with names, as they are entered into an input box.It does not seem to work i have tried many other methods with the array but to no success.
thanks a lot.
VB.NET Syntax (Toggle Plain Text)
Dim namearray() As String Dim i As Integer name = InputBox("Enter the candidates name:", "candidatename", "", 500, 500) name = namearray(i) i = i + 1
thanks a lot.
VB.NET Syntax (Toggle Plain Text)
Dim namearray() As String Dim NewName As String Dim i As Integer i = 0 NewName = InputBox("Enter the candidates name:", "candidatename", "", 500, 500) Do Until String.IsNullOrEmpty(NewName) ReDim Preserve namearray(i) namearray(i) = NewName i += 1 NewName = InputBox("Enter the candidates name:", "candidatename", "", 500, 500) Loop
Teme64 @ Windows Developer Blog
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 10
Why not storing them in a List(Of String)?
VB.NET Syntax (Toggle Plain Text)
Dim listOfNames As New List(Of String) Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim newName As String = "" newName = InputBox("Enter the candidates name:", _ "candidatename", "", 500, 500) If Not String.IsNullOrEmpty(newName) Then listOfNames.Add(newName) End If BindListbox() End Sub Private Sub BindListbox() Me.ListBox1.Items.Clear() Try Me.ListBox1.Items.AddRange(listOfNames.ToArray) Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub
Last edited by 4advanced; Feb 6th, 2009 at 3:40 am. Reason: typo
As per the logic of execution your code, if you want to fill the array in let say button_1 click and then use the array in another sub, you have to declare the array in the form declaration not in the same sub. or else you will be able to use that Array?
vb.net Syntax (Toggle Plain Text)
' Form1 Declaration Dim aCandidate(0) As String ' sub Button6_Click Dim I As Integer I = UBound(aCandidate, 1) + 1 ReDim Preserve aCandidate(I) aCandidate(I) = InputBox("Enter the candidates name:", "candidatename", "", 500, 500)
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: DateTime field - How do I assign a time other than current?
- Next Thread: Reterieve data from mdb and display in listbox
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access add arithmetic array assignment basic binary bing box button buttons center check code combobox component connectionstring convert cpu crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist editvb.net excel file-dialog firewall folder ftp google hardcopy image images isnumericfuntioncall login math memory mobile ms mssqlbackend mysql navigate net networking opacity output peertopeervideostreaming picturebox1 port print printpreview problemwithinstallation project record reports" reuse save savedialog searchbox serial soap storedprocedure string tcp temp text textbox timer toolbox trim updown useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio web wpf





