Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VB how to connect two sub's

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default 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
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VB how to connect two sub's

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?

"Libby" wrote in message ...
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Connect different worksheets Marten Excel Worksheet Functions 2 October 16th 09 04:00 AM
Connect Two Cells Freshman Excel Worksheet Functions 3 May 20th 08 05:42 PM
Connect PC to UNIX via TCP/IP [email protected] Links and Linking in Excel 0 January 20th 07 09:34 PM
Excel cannot connect to web Ltat42a Excel Discussion (Misc queries) 0 May 29th 06 05:18 PM


All times are GMT +1. The time now is 04:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"