Copy Dynamic Array Into Hashtable? [2005]
Hi!
I'm looking for a way to copy the values stored in strWords into a hashtable instead of showing them in the TextBox2.
I know that there's HashTableName.CopyTo but I just can't find something similar that suits my needs or am I just missing something?
VB Code:
Dim String1 As String
Dim String2 As String
Dim i As Short
String1 = TextBox1.Text
MsgBox(String1)
String2 = String1.Replace(" ", "")
String2 = String2.Replace(".", ",")
strWords = Split(String2, ",")
MsgBox(String2)
For i = 0 To UBound(strWords)
TextBox2.Text = TextBox2.Text & strWords(i) & vbCrLf
Next
Re: Copy Dynamic Array Into Hashtable? [2005]
A harshtable is used to store key/value pair data. To store a new value pair, you just call its Add member and pass in the key and value as a pair.
In your case, you can do like this:
VB Code:
Private hshTable As New System.Collections.HashTable 'Declare a new harsh table with class scope
For i = 0 To UBound(strWords)
hshTable.Add("word" & i, strWords(i)) 'The key is wordx, the value is strWords(x)
Next
Re: Copy Dynamic Array Into Hashtable? [2005]
Thanks alot :D
I'll have a go at it when I'm back home.