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 resolve the error.
This is not homework for a class. It is self-study using books.
Code:
Please help resolve the error.
This is not homework for a class. It is self-study using books.
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 Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fileName As String
Dim Commands As New Commands
If RadioButton1.Checked = True Then
fileName = "c:\test_3\johnson.pdf"
End If
If RadioButton2.Checked = True Then
' Else
fileName = "c:\test_3\ross.pdf"
End If
MessageBox.Show("File name is: " + fileName)
Commands.OpenFile()
End Sub
End Class
The following code causes the error:Commands.OpenFile()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you need to pass the parameter in as explained above
ASKER