Hi!
How to open HTML file in VB?
Thanks!
Hi!
How to open HTML file in VB?
Thanks!
to open a html file from the hard disc you can use this method
put a textbox +commandbutton and use this code:
see that you enter the path of the htm file without any spaces.
Option Explicit
Private Sub Command1_Click()
Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE" & Space(1) & Text1, vbNormalFocus
End Sub
'check the path of the iexplore.exe in your hard disc.
or
insert an ole control on form and insert the object from file say "C:\my documents\mypage.htm"
this will appear as an icon. when you double click, the page opens.
HI
You just add microsoft internet control in your component and your form.
eg.
webbrowser name to yahoomail, command button
Private Sub Command1_Click()
' u can place html file also
' Yahoomail.Navigate (htmlfilenam)
Yahoomail.Navigate ("http://mail.yahoo.com/?.intl=us")
First, to open an any file, even HTML:
Imports System
Imports System.IO
Class Test
Public Shared Sub Main()
Try
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New StreamReader("TestFile.html")
Dim line As String
' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()
Console.WriteLine(Line)
Loop Until line Is Nothing
sr.Close()
Catch E As Exception
' Let the user know what went wrong.
Console.WriteLine("The file could not be read:")
Console.WriteLine(E.Message)
End Try
End Sub
End Class
Next, to find the app path:
use Application.ExecutablePath
Put a label on the form and use this ...
Code:1. Private Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long 2. Private Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long 3. 4. Private Const IDC_HAND = 32649& 5. 6. Private Sub label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 7. If X >= 0 And Y >= 0 And X < label1.Width And Y < label1.Height Then 8. SetCursor LoadCursor(0, IDC_HAND) 9. End If 10. End Sub
Bookmarks