Hello, I'm trying to create a click event for a label on my form that will display a clickable link that will open in my default browser. I get the link to display but it not clickable then an error: "Unable to cast object of type 'System.Windows.Forms.MouseEventArgs' to type 'System.Windows.Forms.LinkLabelLinkClickedEventArgs'."
Not sure what this means. What can I do to correct this? Thanks in advance.
Not sure what this means. What can I do to correct this? Thanks in advance.
Code:
Imports System.IO
Public Class Form1
Private Sub GenerateHTMLFileButton_Click(sender As System.Object, e As System.EventArgs) Handles GenerateHTMLFileButton.Click
Dim M, N As Integer
Dim I, J As Integer
Dim str As String
Try
M = Integer.Parse(StartTextBox.Text)
Catch ex As Exception
str = "Please enter an integer!"
MessageBox.Show(Str, "Ray", MessageBoxButtons.OK, MessageBoxIcon.Error)
With StartTextBox
.SelectAll()
.Focus()
End With
Exit Sub
End Try
Try
N = Integer.Parse(EndTextBox.Text)
Catch ex As Exception
Str = "Please enter an integer!"
MessageBox.Show(Str, "Ray", MessageBoxButtons.OK, MessageBoxIcon.Error)
With EndTextBox
.SelectAll()
.Focus()
End With
Exit Sub
End Try
If M > N Then
str = "Ending value should be greater than the starting value!"
Str &= "Please try again."
MessageBox.Show(str, "ray", MessageBoxButtons.OK, MessageBoxIcon.Error)
With EndTextBox
.SelectAll()
.Focus()
End With
Exit Sub
End If
HTMLFileHyperlink.Visible = False
Dim MyOutputFile As StreamWriter
Dim FileFullPath As String
FileFullPath = Application.StartupPath & "\" & "MultiplicationTableVS.htm"
MyOutputFile = New StreamWriter(FileFullPath)
MyOutputFile.WriteLine("<HTML>")
MyOutputFile.WriteLine("<head><title>Mulitplication Table " & M & " x " & N & "</title></head>")
MyOutputFile.WriteLine("<body>")
MyOutputFile.WriteLine("<h1>Multiplication Table" & M & " x " & N & "</h1>")
MyOutputFile.WriteLine("<h2>By Sierra Ray</h2>")
MyOutputFile.WriteLine("<hr style=""color:red"" />")
MyOutputFile.WriteLine("<table border=""3"">")
MyOutputFile.WriteLine("<tr>")
MyOutputFile.WriteLine("<th> </th>")
For I = M To N
MyOutputFile.WriteLine("<th>" & I & "</th>")
Next
For I = M To N
MyOutputFile.WriteLine("<tr>")
MyOutputFile.WriteLine("<th>" & I & "</th>")
For J = M To N
MyOutputFile.WriteLine("<td>" & I * J & "</td>")
Next
MyOutputFile.WriteLine("</tr>")
Next
MyOutputFile.WriteLine("</table>")
MyOutputFile.WriteLine("</body>")
MyOutputFile.WriteLine("</HTML>")
If MyOutputFile IsNot Nothing Then
MyOutputFile.Close()
End If
HTMLFileHyperlink.Text = FileFullPath
HTMLFileHyperlink.Visible = True
End Sub
Private Sub HTMLFileHyperlink_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles HTMLFileHyperlink.Click
Process.Start(HTMLFileHyperlink.Text)
End Sub
End Class