|
-
Oct 7th, 2000, 11:18 PM
#1
Thread Starter
New Member
I'm writing a program that requires opening a file based on what is entered into a text box, ie if 12345 is entered in the text box, 12345.txt will be opened. how would this be accomplished?
-
Oct 7th, 2000, 11:48 PM
#2
You could use the ShellExecute api function.
Code:
Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal _
lpOperation As String, ByVal lpFile As String, ByVal _
lpParameters As String, ByVal lpDirectory As String, ByVal _
nShowCmd As Long) As Long
Public Const SW_SHOWNORMAL = 1
ShellExecute Me.hwnd, vbNullString, Text1.text, vbNullString, "c:\", SW_SHOWNORMAL
Or the regular Shell function:
Code:
Shell "Notepad.exe " & Text1.text, vbNormalFocus
-
Oct 7th, 2000, 11:53 PM
#3
Thread Starter
New Member
first, thank you for your reply. Looking at your example, would that open the 12345.txt in notepad? i was more going for opening the file for input into my program, so Open "C:\ (strinputtext) .txt" for Iput as #1. Is this possible?
Pie, I'm just going to go like this and if you get eaten, it's your own fault.- Homer Simpson
-
Oct 7th, 2000, 11:59 PM
#4
To read files into a text box:
Code:
Open "C:\12345.txt" For Input As #1
Text1.Text = Input$(LOF(1), 1)
Close #1
Is this what you wanted?
-
Oct 8th, 2000, 12:08 AM
#5
Thread Starter
New Member
my bad my bad. First I appreciate your patients, I can be quit unclear sometimes. I want to open a file for input, the name of the file to be opened being determined by what is entered in the text box. thank you much this might help
(purely an example)
Pie, I'm just going to go like this and if you get eaten, it's your own fault.- Homer Simpson
-
Oct 8th, 2000, 12:20 AM
#6
Which is exactly what I showed you. If someone enters something in a textbox, and clicks a command button, the file will be loaded.
Code:
Private Sub Command1_Click()
ShellExecute Me.hwnd, vbNullString, Text1.text, vbNullString, "c:\", SW_SHOWNORMAL
End Sub
-
Oct 8th, 2000, 08:01 AM
#7
Doughboy: Try this
Code:
Open Text1.Text & ".txt" For Input as #1
That's all there is to it...
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
|