VB how to connect two sub's

C

Christof

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
 
L

Libby

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
 
C

Christof

yeah, that's what I've searched for *g* thx a lot :D
But I recognized, that I forgot one problem. My Sub MakeList does only
work when there's a carriage return (is it called like this?). But the
files it deals with are of different types, sometimes between the
url's is a carriage return, and sometimes only a freespace. To work
correctly it should cope with both types. Can someone help me?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top