Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Connect different worksheets | Excel Worksheet Functions | |||
Connect Two Cells | Excel Worksheet Functions | |||
Connect PC to UNIX via TCP/IP | Links and Linking in Excel | |||
Excel cannot connect to web | Excel Discussion (Misc queries) |