• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 142
  • Last Modified:

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
0
michaeldi
Asked:
michaeldi
  • 3
  • 2
1 Solution
 
mcriderCommented:
First part:

Shell "Programname.exe",vbNormalFocus

Second part I'm not sure I understand... Are you trying to show the contents of a file in a listbox??  You should be using a textbox...


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

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
michaeldiAuthor Commented:
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"
0
 
VbmasterCommented:
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")

0
 
michaeldiAuthor Commented:
thnak to both of you I willshare the points for
thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now