Mark01
asked on
VB.Net Argument Not Specified For Parameter Error
I am trying to work with two radio buttons in a simple VB.net app that allows a user to select and open a PDF using the Process object. One PDF will be assigned to each radio button. The code is shown below. I get the following error: "Argument not specified for parameter ‘AFileName’ of ‘Public Sub OpenFile(AFileName As String)’." Please help me resolve the error.
The following line causes the error (line 6 in Public Class Form1):
Full Code:
The following code runs without any errors.
The following line causes the error (line 6 in Public Class Form1):
cmd.OpenFile()
Full Code:
Public Class Commands
Public Sub OpenFile(ByVal AFileName As String)
Dim psi As New ProcessStartInfo()
psi.UseShellExecute = True
psi.FileName = AFileName
Process.Start(psi)
End Sub
End Class
Public Class Form1
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
If radPDF1.Checked = True Then
Dim fileName As String
Dim cmd As New Commands
cmd.OpenFile()
If radPDF1.Checked = True Then
fileName = "c:\test_3\johnson.pdf"
Else
fileName = "c:\test_3\ross.pdf"
End If
End If
End Sub
End Class
The following code runs without any errors.
Public Class Form1
Public Sub OpenFile(ByVal AFileName As String)
Dim psi As New ProcessStartInfo()
psi.UseShellExecute = True
psi.FileName = AFileName
Process.Start(psi)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
Dim fileName As String
If radPDF1.Checked = True Then
fileName = "c:\test_3\johnson.pdf"
Else
fileName = "c:\test_3\ross.pdf"
End If
OpenFile(fileName)
End Sub
ASKER
I get the following errors:
(1)
Name 'cmd' is not declared.
(2)
Name 'fileName' is not declared.
(1)
Name 'cmd' is not declared.
(2)
Name 'fileName' is not declared.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Moderator: How do I award points?
ASKER
No more errors! Thank you, Norie.
Open in new window