[ACCEPTED]-Why does a VB.Net function that returns string only actually return a single character?-syntax
Note: this answer was originally written by the OP, Kibbee, as a self-answer. However, it was written in the body of the question, not as an actual separate answer. Since the OP has refused repeated requests by other users, including a moderator, to repost in accordance with site rules, I'm reposting it myself.
After trying a hundred different things, refactoring 22 my code, stepping through the code in the 21 debugger many times, and even having a co-worker 20 look into the problem, I finally, in a flash 19 of genius, discovered the answer.
At some 18 point when I was refactoring the code, I 17 changed the function to get rid of the Value 16 parameter, leaving it as follows:
Public Function GetSomeStringValue() As String ... Code Goes here Return Some_Multicharacter_String End Function
However, I 15 neglected to remove the parameter that I 14 was passing in when calling the function:
SomeStringValue = GetSomeStringValue(Value)
The 13 compiler didn't complain because it interpreted 12 what I was doing as calling the function 11 without brackets, which is a legacy feature 10 from the VB6 days. Then, the Value parameter 9 transformed into the array index of the 8 string (aka character array) that was returned 7 from the function.
So I removed the parameter, and 6 everything worked fine:
SomeStringValue = GetSomeStringValue()
I'm posting this 5 so that other people will recognize the 4 problem when/if they ever encounter it, and 3 are able to solve it much more quickly than 2 I did. It took quite a while for me to solve, and 1 I hope I can save others some time.
More Related questions