Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error in this simple code

Status
Not open for further replies.

bizzzzzzz

Technical User
Jan 20, 2005
15
CA
why it dont find my usager(i).text?

Private Sub cmd1_Click()
Set objTextFileW = objFSO.OpenTextFile("d:\tools\transfert.dat", ForWriting, True)
For i = 1 To 6
If usager(i).Text <> "" Then
objTextFileW.WriteLine (usager(i).Text & "," & Source(i).Text & "," & dest(i).Text)
Next
objTextFileW.Close
End Sub

Thanks
 
this is my code with some bugs fix.
but i'am still unable to do my "for next" with use the "i"

Private Sub cmd1_Click()
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFileW = objFSO.OpenTextFile("d:\tools\transfert.dat", ForAppending, True)
'For i = 1 To 6
If usager1.Text <> "" Then
objTextFileW.WriteLine (usager1.Text & "," & source1.Text & "," & dest1.Text)
End If
'Next
objTextFileW.Close
End Sub
 
Try
Code:
debug.print usager(i).text
before the
Code:
objTextFileW.WriteLine (usager(i).Text & "," & Source(i).Text & "," & dest(i).Text)
To see what value is returned by usager(i).text

Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
Compile error:
Sub or fonction not defined

yes i is now an as interger

but still an issue
 
the code work well like this

Private Sub cmd1_Click()
Dim y As Integer
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFileW = objFSO.OpenTextFile("d:\tools\transfert.dat", ForAppending, True)
For y = 1 To 6
If usager1.Text <> "" Then
objTextFileW.WriteLine (usager1.Text & "," & source1.Text & "," & dest1.Text)
End If
Next
objTextFileW.Close
End Sub

but now my objectif is to change usager1.text with something like this usager(y).text
but it stop on usager with a compile error
 
Is it appearing on the loop or on the first line of the loop the
Code:
If usager(i).Text <> "" Then
part of the code??

If so is the name usager correct??

Harleyquinn

---------------------------------
For tsunami relief donations
 
exactly there If usager(i).Text <> "" Then
the first place where it find usager
 
Have you got the control array set up with your textboxes??

The easiest way to create a control array is to copy a text box (in your case usager) and paste it onto your form. VB will ask you if you wish to create a control array. What will happen then is that all of the textboxes will be called usager but wuill have a numeric identifier at the end e.g. usager(1). Then you can use the if usager(i) statement.

Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
Thanks a lot for all your help, have a nice day

A WOW for your time too


Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top