|
-
Jul 16th, 2008, 10:53 PM
#1
Thread Starter
New Member
How do you get a file to start in Visual Basic 6
Lets say you made a command button that when pressed would open some type of file. How do you do that?
-
Jul 16th, 2008, 11:07 PM
#2
Hyperactive Member
Re: How do you get a file to start in Visual Basic 6
If you want to just open a text file, for example, just use the open statement.
If your file is located at C:\MytextFile.txt then your statement would be as simple as:
Open "C:\MytextFile.txt" for input as #1
Then to get the first line of the text, if you had dimensioned MyLine as a string, you'd simply have:
Input #1, MyLine
Everytime you repeat that, you'll read the next line. When you're done, have the command:
Close #1
In Visual Basic just run help and look at OPEN. There are different ways you can open something, such as for input, for append, for output, etc. Data can be sequential or random. And so on.
-
Jul 17th, 2008, 12:00 AM
#3
Re: How do you get a file to start in Visual Basic 6
also you may not want to hard code in the file path so using a CommonDialog control will allow the user to browsae for the desired file to open.
File Open FAQ:
http://www.vbforums.com/showthread.php?t=342619
http://www.vbforums.com/showthread.php?t=405051
CommonDialog ex:
Code:
Option Explicit
'Add a CommonDialog control to your form.
'Project > Components > Controls tab > "Microsoft Common Dialog control" > OK
Private Sub Command1_Click()
On Error GoTo MyError
With CommonDialog1
.CancelError = True
.DialogTitle = "Common Dialog Example"
.Filter = "Text files only (*.txt)|*.txt|All files (*.*)|*.*"
.FilterIndex = 1
.Flags = cdlOFNHideReadOnly Or cdlOFNOverwritePrompt Or cdlOFNPathMustExist
.InitDir = App.Path
.ShowSave 'or .ShowOpen
End With
'Do your save/open stuff here
'Use the CommonDialog1.FileName property to get the full path and file name selected
'
Exit Sub
MyError:
If Err.Number <> cdlCancel Then
MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbExclamation, "Save"
End If
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 17th, 2008, 01:55 AM
#4
Re: How do you get a file to start in Visual Basic 6
I think, exe files can be opened using shell function...
Code:
Shell App.path & "\game.exe", vbnormalfocus
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Jul 17th, 2008, 01:58 AM
#5
Re: How do you get a file to start in Visual Basic 6
is the complete path of the exe file.
is the type of display (for maximized, minimize, normal, etc...)
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|