michaeldi
asked on
Basic VB Function
Im very new to VB and I would like some help on something im doing that I have to do in a hurry..
I would like to set up two buttons
the first on click event should simply run a file ie an *.exe
The second button should display in my my List box ="INFO" the contents of a text file in a particular location that I can specify ...
Can you help me with how I can go about doing such a program
Thanks in advance
I would like to set up two buttons
the first on click event should simply run a file ie an *.exe
The second button should display in my my List box ="INFO" the contents of a text file in a particular location that I can specify ...
Can you help me with how I can go about doing such a program
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this function, it reads text from a file. just set the Textbox.Text = InputFile(filename)
Function InputFile(Filename As String) As String
Dim Filenr As Long
Filenr = FreeFile
Open Filename For Input Lock Read As Filenr
InputFile = Input$(LOF(Filenr), Filenr)
Close Filenr
End Function
Function InputFile(Filename As String) As String
Dim Filenr As Long
Filenr = FreeFile
Open Filename For Input Lock Read As Filenr
InputFile = Input$(LOF(Filenr), Filenr)
Close Filenr
End Function
ASKER
Can you just confirm which parts I do actually have to change because I cant seem to get it working: ive tried all sorts and im no nearer
heres where im at: thanks
THE BUTTON
Private Sub Command6_Click()
TextDisplay.Text = C:Y2K (FileName)
End Sub
THE MODULE
Function InputFile(FileName As String) As String
Dim Filenr As Long
Filenr = FreeFile
Open FileName For Input Lock Read As Filenr
InputFile = Input$(LOF(Filenr), Filenr)
Close Filenr
End Function
EXTRAS
My file name is "C:Y2K.TXT"
my Textbox name is "TextDisplay"
heres where im at: thanks
THE BUTTON
Private Sub Command6_Click()
TextDisplay.Text = C:Y2K (FileName)
End Sub
THE MODULE
Function InputFile(FileName As String) As String
Dim Filenr As Long
Filenr = FreeFile
Open FileName For Input Lock Read As Filenr
InputFile = Input$(LOF(Filenr), Filenr)
Close Filenr
End Function
EXTRAS
My file name is "C:Y2K.TXT"
my Textbox name is "TextDisplay"
How do you get that it's supposed to be "C:Y2K (FileName) " from my comment? ;)
Replace the line
TextDisplay.Text = C:Y2K (FileName)
with
TextDisplay.Text = InputFile("C:\Y2K.TXT")
Replace the line
TextDisplay.Text = C:Y2K (FileName)
with
TextDisplay.Text = InputFile("C:\Y2K.TXT")
ASKER
thnak to both of you I willshare the points for
thanks
thanks
ASKER