hello everyone,

I am working on a little program (game) is called Pig latin. I created a sub procedure and I passed the word to be converted by value and the piglatin word byref.

Now when I call the procedure in the button click event I get the wavy green line under the variable passed by reference but the program works ok.
Call Convert_to_Pig_Latin(strOriginalWord, strPigLatin)
The error message when I hover my mouse over the green line says " Variable 'strPigLatin' is passed by reference before it has been assigned a value. A null reference exception could result at runtime."

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim strOriginalWord As String
        Dim strPigLatin As String

        
        strOriginalWord = TextBox1.Text.Trim


        Call Convert_to_Pig_Latin(strOriginalWord, strPigLatin)

        Label1.Text = strPigLatin
end sub

I need to get ride of the wavy green line please help.

Regards

Dim strOriginalWord As String = nothing
        Dim strPigLatin As String = nothing

This will fix the green wavy line

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.