We help IT Professionals succeed at work.
Get Started

VB.Net Argument not Specified for Parameter Error

469 Views
Last Modified: 2018-02-12
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

Comment
Watch Question
CERTIFIED EXPERT
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 2 Answers and 4 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE