Results 1 to 3 of 3

Thread: Copy Dynamic Array Into Hashtable? [2005]

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    7

    Post 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:
    1. Dim String1 As String
    2.      Dim String2 As String
    3.      Dim i As Short
    4.  
    5.         String1 = TextBox1.Text
    6.        
    7. MsgBox(String1)
    8.  
    9.         String2 = String1.Replace(" ", "")
    10.  
    11.         String2 = String2.Replace(".", ",")
    12.  
    13.         strWords = Split(String2, ",")
    14.        
    15. MsgBox(String2)
    16.  
    17.         For i = 0 To UBound(strWords)
    18.             TextBox2.Text = TextBox2.Text & strWords(i) & vbCrLf
    19.         Next

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    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:
    1. Private hshTable As New System.Collections.HashTable 'Declare a new harsh table with class scope
    2.  
    3.  For i = 0 To UBound(strWords)
    4.             hshTable.Add("word" & i, strWords(i)) 'The key is wordx, the value is strWords(x)
    5.         Next

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    7

    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
  •  



Click Here to Expand Forum to Full Width