English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

This is Visual Basic 6.0. (No cheating now)
Can anyone tell me the results that will be displayed in the Immediate window when the procedure Test is called?

Public Sub Test()
Dim sTemp As String
Dim bRetVal As Boolean



sTemp = "Original"
TestFunction (sTemp)
Debug.Print "Result 1 = " & sTemp

sTemp = "Original"
bRetVal = TestFunction(sTemp)
Debug.Print "Result 2 = " & sTemp

sTemp = "Original"
bRetVal = TestFunction((sTemp))
Debug.Print "Result 3 = " & sTemp

End Sub


Private Function TestFunction(sTest As String) As Boolean
sTest = "Changed"

TestFunction = True 'Set a return value
End Function

2007-03-16 06:04:24 · 3 answers · asked by Jeff R 2 in Computers & Internet Programming & Design

I know the answer. It's just a quiz for anyone who might find it fun.

2007-03-16 06:22:09 · update #1

3 answers

VB6 passes everything by reference by default.

So:
Result 1 = Changed
Result 2 = Changed
Result 3 = Changed


It would have been a better quiz if you didn't use the same variable name in the function, as you'd see the variable in the calling function get overwritten with each call to TestFunction.

2007-03-16 16:02:47 · answer #1 · answered by Vegan 7 · 0 0

Result 1 = Original
Result 2 = True
Result 3 = Original

2007-03-16 06:09:16 · answer #2 · answered by dmc177 4 · 1 1

wtf u just want us to do it for u lol

2007-03-16 06:08:15 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers