Link to home
Start Free TrialLog in
Avatar of Mark01
Mark01Flag for United States of America

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:
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

Open in new window


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

Open in new window

The following code causes the error:
Commands.OpenFile()

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mark01

ASKER

Thank you, Andy and Ryan.
Avatar of Bill
Bill

you need to pass the parameter in as explained above