Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing and returning variable

Status
Not open for further replies.

ldCycler

Instructor
Mar 6, 2007
3
US
I am working with a procedure and a module. In the procedure, a string variable (selectStatement) is created and assigned the word "Password". I then use that variable at the module level to update that variable with the Select statement text in the Case statement. It works until I return to the calling procedure where the variable selectStatement is the word "Password" again.

Below is the code. Can you tell me what I am doing wrong? Thank you

Procedure code:
Dim selectStatement as string = "Password"
'call the GetSelectStatement module and get selectStatement string value
GetSelectStatement(selectStatement)

Module level:
Module SelectTheStatement
Public Class GetStatements
End Class

Friend Function GetSelectStatement(ByVal selectStatement As String)

Select Case selectStatement
Case "Password"
selectStatement = "Select * from TblPasswords"
End Select

End Function


End Module
 
change

Friend Function GetSelectStatement(ByVal selectStatement As String)

to:

Friend Function GetSelectStatement(ByRef selectStatement As String)


- or -

Code:
Friend Function GetSelectStatement(ByVal selectStatement As String) as string

        Select Case selectStatement
            Case "Password"
                selectStatement = "Select * from TblPasswords"
        End Select
      return selectStatement

    End Function

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top