VB how to connect two sub's
If you wanted to run one immediately after running the
other you could use the Call statement.
For example if you wanted to run Sub MakeURLText() from
Sub MakeList() then type Call MakeURLText in the Sub
Makelist code, at the point where you want to bring it in.
Hope this helps
Libby
-----Original Message-----
Hi there everyone
I am a noob in this program, although I have created one
sub myself
and got help with another sub. What I want to do now, is
to connect
them. I couldn't do it without getting error-messages.
Hope u can help me to do so or make alternative
suggestions
_________________________________________________ _
Part 1:
Sub MakeList()
Const file1 = "P:\temp\oldtest.txt"
Const file2 = "P:\temp\newtest.txt"
Const ForWriting = 2
Dim Text
Dim fso, fi1, fi2
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(file1) Then
Set fi1 = fso.OpenTextFile(file1)
Set fi2 = fso.OpenTextFile(file2, ForWriting, True)
Do While Not (fi1.atEndOfStream)
Text = fi1.Readline
fi2.WriteLine (Text)
Loop
End If
End Sub
_________________________________________________ _
Part 2:
Sub MakeURLText()
Dim FName As String
Dim Fnum As Long
Dim NewText As String
Dim MyURL As String
FName = "P:\temp\newtest.txt"
Fnum = FreeFile
NewText = "( "
Open FName For Input As Fnum
Do While Not EOF(Fnum)
Line Input #Fnum, MyURL
NewText = NewText & "url contains " & Chr(34) _
& MyURL & Chr(34) & " or "
Loop
Close Fnum
NewText = Left(NewText, Len(NewText) - 4) & " )"
FName = "P:\temp\newtest.txt"
Fnum = FreeFile
Open FName For Output As Fnum
Print #Fnum, NewText
Close Fnum
End Sub
hope u can help me, thx for your attention :)
Greets, Christof
.
|