Avatar of Mark01
Mark01
Flag 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

Visual Basic.NET.NET Programming

Avatar of undefined
Last Comment
Bill

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Ryan Chong

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
AndyAinscow

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Mark01

ASKER
Thank you, Andy and Ryan.
Bill

you need to pass the parameter in as explained above
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes