Link to home
Start Free TrialLog in
Avatar of michaeldi
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
ASKER CERTIFIED SOLUTION
Avatar of mcrider
mcrider

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of michaeldi
michaeldi

ASKER

Yes I dont mind how it display so when I click on the button the TEXTBOX will show text of a specfied file..
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

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"
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")

thnak to both of you I willshare the points for
thanks