![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
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. |
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
|
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
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 SubMethod or Datamemember not found.
__________________
And there was much rejoicing... Yay.... |
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() |
what line?
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
|
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.... |
|
|
|
|
|
#6 |
|
Expert Programmer
|
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|