Home All Groups Group Topic Archive Search About

variable help in vbscript



Author
9 Aug 2005 4:15 PM
sleepy
HI all i'm trying to read a text file then display the results in a msgbox
but i'm havein trouble useing a variable what i'm doing is reading a txt file
then i need a variable to put the text into a msg box  here is example of
what i'm doing
i would love some help on this thank you very much

Function ReadTextFileTest
   Const ForReading = 1, ForWriting = 2, ForAppending = 8
   Dim fso, f, Msg
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.OpenTextFile("test.txt", ForReading)
   ReadTextFileTest = f.Read(5)
End Function

msgbox "$f", 1, (f)

Author
9 Aug 2005 11:46 PM
Marty List
Show quote
"sleepy" <sle***@discussions.microsoft.com> wrote in message
news:DFE1173C-6411-4F8B-AD28-009CECDDDA24@microsoft.com...
> HI all i'm trying to read a text file then display the results in a msgbox
> but i'm havein trouble useing a variable what i'm doing is reading a txt file
> then i need a variable to put the text into a msg box  here is example of
> what i'm doing
> i would love some help on this thank you very much
>
>  Function ReadTextFileTest
>    Const ForReading = 1, ForWriting = 2, ForAppending = 8
>    Dim fso, f, Msg
>    Set fso = CreateObject("Scripting.FileSystemObject")
>    Set f = fso.OpenTextFile("test.txt", ForReading)
>    ReadTextFileTest = f.Read(5)
> End Function
>
> msgbox "$f", 1, (f)


I'm not sure if this is what you are asking, but try this:

Dim MyVariable
MyVariable = ReadTextFileTest
MsgBox MyVariable, vbOKCancel, "Title/Caption"


Read the syntax for the MsgBox function:
http://msdn.microsoft.com/library/en-us/script56/html/vsfctMsgBox.asp

AddThis Social Bookmark Button