Welcome to Dream.In.Code
Become a VB Expert!

Join 137,230 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,867 people online right now. Registration is fast and FREE... Join Now!




Question re: Arrays

 
Reply to this topicStart new topic

Question re: Arrays

ishin2
15 Mar, 2007 - 05:55 AM
Post #1

New D.I.C Head
*

Joined: 15 Mar, 2007
Posts: 1


My Contributions
CODE

'Words box
        Dim word As String = ""
        Dim words As ArrayList = New ArrayList
        Dim index As Integer = 0

        For i As Integer = 0 To S.Length - 1
            Dim Ch As Char = S.Chars(i)
            If (Char.IsLetter(Ch) = True) Then
                word = word & S.Chars(i).ToString
            End If
            If Char.IsWhiteSpace(Ch) = True Then
                MessageBox.Show(word)
                'ReDim Preserve words(UBound(words) + 1)
                'words(index) = word
                'messgebox.show(words(1))
                index = index + 1
                word = ""

            End If


Split the text (from textbox input) into words ignoring all characters that are NOT letters. Every time you run into a character that is not a letter treat it as word delimiter. I am a new student taking VB class and having a hard time programming this. can anyone help? how can i put each word into array and display in list box

This post has been edited by William_Wilson: 15 Mar, 2007 - 07:27 AM
User is offlineProfile CardPM
+Quote Post

m2s87
RE: Question Re: Arrays
15 Mar, 2007 - 07:48 AM
Post #2

D.I.C Regular
Group Icon

Joined: 28 Nov, 2006
Posts: 390



Thanked: 1 times
Dream Kudos: 1225
My Contributions
It would be generally something like:
CODE
class My1

dim withevents wordbank as new My2
private sub wordified() handles wordbank.done
    msgbox("Text has been splitted in to " & wordbank.words.getupperbound(0)-1 & " words.")
end sub

private sub activier(something here...) handles button1.click
    wordbank.text=Me.textbox.text
end sub

end class

class My2
   private alp() as Char = {a;b;c;d;e;f;g;h;i;j;k;l;m;n;o;p;q;r;s;š;z;ž;t;u;v;w;õ;ä;ö;ü;x;y}
   Private x As string
   Public words() As string

   Public Property text() As string
   Get
       Return x
   End Get
   Set(ByVal Value As string)
      x = value
      p = pure(x)

      rem split the recorrected text to words
      words=split(pure, " ")
   End Set
End Property

private function pure(byval text as string) as string
      rem get the text that is written used by letters in alphabet
      for i as integer = 0 to len(x)
          for j=0 to alph.getupperbound(0)-1
             if mid(x,i,1)=alp(j) or mid(x,i,1)=StrConv(alp(j), vbuppercase) then
               pure&=mid(x,i,1)
               exit for
             else
               if j=alph.getupperbound(0) then pure&=" "
          next j
      next i
end function

    rem eliminate reapeating spaces
    rem look at the snippets
end sub
end class


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 03:18PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month