|
-
Nov 19th, 2006, 04:35 PM
#1
Thread Starter
New Member
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
-
Nov 19th, 2006, 08:26 PM
#2
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
-
Nov 20th, 2006, 01:56 AM
#3
Thread Starter
New Member
Re: Copy Dynamic Array Into Hashtable? [2005]
Thanks alot
I'll have a go at it when I'm back home.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|