Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 24th, 2005, 11:34 AM   #1
Cipher
Hobbyist Programmer
 
Cipher's Avatar
 
Join Date: Feb 2005
Location: /home/cipher
Posts: 123
Rep Power: 4 Cipher is on a distinguished road
Send a message via AIM to Cipher Send a message via MSN to Cipher
YAHOO! ID Checker[Solved]

I need to know how to populate a listbox based on spaces. I have already opened the file and read from it. Now how to I populate the listbox based on spaces. Like if there is a space the listbox automattically adds a new item. like if i have this in my text: bob
army
it will add a serperate entery in the listbxo for each. the list will look like bob and army.

 here is some of the codee
  
  Private Sub Command1_Click()
  cmd.Filter = ".txt|*.txt"
  cmd.ShowOpen
  On Error GoTo Errorcheck:
  Dim FileNum As Integer
  FileNum = FreeFile
  Open cmd.FileName For Input As #FileNum
  Label1.Caption = Input(LOF(FileNum), #FileNum)
  Close #FileNum
  List1.AddItem (Label1.Caption)
  Errorcheck:
  Exit Sub
  End Sub
__________________
And there was much rejoicing... Yay....

Last edited by Cipher; Mar 25th, 2005 at 11:00 AM.
Cipher is offline   Reply With Quote
Old Mar 24th, 2005, 1:36 PM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
You want the Split function, mate:

http://www.w3schools.com/vbscript/func_split.asp
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 24th, 2005, 2:02 PM   #3
Cipher
Hobbyist Programmer
 
Cipher's Avatar
 
Join Date: Feb 2005
Location: /home/cipher
Posts: 123
Rep Power: 4 Cipher is on a distinguished road
Send a message via AIM to Cipher Send a message via MSN to Cipher
Dim Words() As String
 Private Sub Command1_Click()
 Dim X As Integer
 cmd.Filter = ".txt|*.txt"
 cmd.ShowOpen
 On Error GoTo Errorcheck:
 Dim FileNum As Integer
 FileNum = FreeFile
 Open cmd.FileName For Input As #FileNum
 Label1.Caption = Input(LOF(FileNum), #FileNum)
 Words = Split(Label1.Caption, " ")
 For X = LBound(Words) To UBound(Words)
 	List1.AddItem Words(X)
 Next X
 Close #FileNum
 Errorcheck:
 Exit Sub
 End Sub
 
 Private Sub Command2_Click()
 Dim Add As String
 Add = InputBox("Type what you want to add")
 List1.AddItem (Add)
 End Sub
 
 Private Sub Command3_Click()
 cmd.Filter = "Text File|*.txt"
 Dim X As Integer
 cmd.ShowSave
 Open cmd.FileName For Append As #1
 For X = 0 To List1.ListItem.Count - 1
 Write #1, List1.ListItem.Count
 Next X
 End Sub

Method or Datamemember not found.
__________________
And there was much rejoicing... Yay....
Cipher is offline   Reply With Quote
Old Mar 24th, 2005, 2:19 PM   #4
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
what line?
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Mar 24th, 2005, 3:57 PM   #5
Cipher
Hobbyist Programmer
 
Cipher's Avatar
 
Join Date: Feb 2005
Location: /home/cipher
Posts: 123
Rep Power: 4 Cipher is on a distinguished road
Send a message via AIM to Cipher Send a message via MSN to Cipher
Never Mind that: now winsock is moving slowly


Dim Words() As String
 Private Sub Command1_Click()
 Dim X As Integer
 cmd.Filter = ".txt|*.txt"
 cmd.ShowOpen
 On Error GoTo Errorcheck:
 Dim FileNum As Integer
 FileNum = FreeFile
 Open cmd.FileName For Input As #FileNum
 Label1.Caption = Input(LOF(FileNum), #FileNum)
 Words = Split(Label1.Caption, " ")
 For X = LBound(Words) To UBound(Words)
 	List1.AddItem Words(X)
 Next X
 Close #FileNum
 Errorcheck:
 Exit Sub
 End Sub
 
 Private Sub Command2_Click()
 Dim Add As String
 Add = InputBox("Type what you want to add")
 List1.AddItem (Add)
 End Sub
 
 Public Sub Command3_Click()
 	cmd.Filter = "Text File|*.txt"
 	cmd.ShowSave
 	Dim lngSave As Long
 	If cmd.FileName = "" Then Exit Sub
 	Open cmd.FileName For Output As #1
 		For lngSave& = 0 To List1.ListCount - 1
 			Print #1, List1.List(lngSave&)
 		Next lngSave&
 	Close #1
 End Sub
 
 
 Private Sub Command4_Click()
 List1.Clear
 End Sub
 
 
 
 
 Private Sub cmdyourmom_click()
 Status.SimpleText = "Checking.."
 Winsock1.Close
 Winsock1.RemoteHost = "edit.yahoo.com"
 Winsock1.RemotePort = "80"
 Winsock1.Connect
 End Sub
 
 Public Function CheckID(YahooId As String)
 Dim Str As String
 Str = "GET http://edit.yahoo.com/config/id_check?.u=&.id=" & YahooId & " HTTP/1.0" + vbCrLf
 Str = Str + "Accept-Language: en-au" + vbCrLf
 Str = Str + "Cookie: B=5bih0t10hqgsu&b=2" + vbCrLf + vbCrLf
 Winsock1.SendData Str
 End Function
 
 Private Sub Command5_Click()
 Winsock1.Close
 Status.SimpleText = "Ready"
 End Sub
 
 Private Sub Winsock1_Connect()
 Call CheckID(Text1.Text)
 End Sub
 
 Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
 Dim Data As String
 Winsock1.GetData Data
 If InStr(1, Data, "is unavailable.") Then Me.Caption = "ID unavailable": GoTo 1
 If InStr(1, Data, "is available!") Then Me.Caption = "ID Available": GoTo 1
 Exit Sub
 1
 Winsock1.Close
 Data = ""
 End Sub
 
 End Sub
 
 Private Sub Form_Load()
 Status.SimpleText = "Ready"
 End Sub
__________________
And there was much rejoicing... Yay....
Cipher is offline   Reply With Quote
Old Mar 27th, 2005, 3:36 PM   #6
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Are you using VB5 by any chance?
You should write your own for loop based on the mid function. Split is actually slower, as it is laboured with a load of Unicode stuff that is hardly ever used, and anyway coding your own is good for the soul.
As in :
where MyString is the string
Dim MyEnum as Integer
Dim Big, Small as String
For MyEnum = 1 to Len(MyString)
Small = Mid(MyString,MyEnum,1)
If Small = " " then
List1.AddItem Big
Big = ""
Else
Big = Big & Small
End If
Next
Rory is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:56 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC