|
-
Jul 15th, 2000, 09:55 PM
#1
Thread Starter
Addicted Member
QUESTION 1
How Can I say open a like open a text file in vb,not into a text window or anything realted to the program, but in the text editor, but not using the shell command.
Question 2
How does the error command work all i have is
Private Sub Command1_Click()
On Error GoTo IEERROR
Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE " + "http://www.yahoo.com", vbNormalFocus
End Sub
Sub IEERROR()
MsgBox "IE NOT FOUND PLEASE COPY PROVIDED LINK.", vbExclamation, "UPDATE ERROR"
End Sub
-
Jul 15th, 2000, 10:18 PM
#2
To view text in your program:
Code:
Open "C:\txtfile.txt" For Input As #1
Text1.Text = Input(LOF(1),#1)
Close #1
And to use the error code, it must be in the same sub/function.
Code:
Private Sub Command1_Click()
On Error GoTo IEERROR
Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE " & "http://www.yahoo.com", vbNormalFocus
Exit Sub
IEERROR:
MsgBox "IE NOT FOUND PLEASE COPY PROVIDED LINK.", vbExclamation, "UPDATE ERROR"
End Sub
And instead of using Shell, you should use ShellExecute.
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
Function ShellToBrowser%(frm As Form, ByVal url$, ByVal WindowStyle%)
Dim api%
api% = ShellExecute(frm.hwnd, "open", url$, "", App.Path, WindowStyle%)
'Check return value
If api% < 31 Then
'error code - see api help for more info
MsgBox App.Title & " had a problem running your web browser. You should check that your browser is correctly installed. (Error #" & Format$(api%) & ")", 48, "Browser Unavailable"
ShellToBrowser% = False
ElseIf api% = 32 Then
'no file association
MsgBox App.Title & " could not find a file association for " & url$ & " on your system. You should check that your browser is correctly installed and associated with this type of file.", 48, "Browser Unavailable"
ShellToBrowser% = False
Else
ShellToBrowser% = True
End If
End Function
Usage:
ShellToBrowser(Me,"http://www.site.com",0)
-
Jul 15th, 2000, 10:31 PM
#3
For this code:
Code:
Private Sub Command1_Click()
On Error GoTo IEERROR
Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE " & "http://www.yahoo.com", vbNormalFocus
Exit Sub
IEERROR:
MsgBox "IE NOT FOUND PLEASE COPY PROVIDED LINK.", vbExclamation, "UPDATE ERROR"
End Sub
You could change it like this:
Code:
Private Sub Command1_Click()
On Error Resume Next
Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE " & "http://www.yahoo.com", vbNormalFocus
End Sub
If there is an error, this will just ignore it and keep your program from getting an error..or making it so that you don't have to show an error, if any.
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
|