function in VB.net

Asked By san san
11-Sep-08 07:41 AM
Earn up to 0 extra points for answering this tough question.
Hi all
I am new to VB.NET.
In some code somewhere I found that

FunctionReadData = "Successfull"

here FubctionReadData is a method/function.
In C# assigning strings to functions like this is not possible.. But in VB.net it's possible..
What is this..? why we r assigning string to function names?

Thanks

  see this

Sagar P replied to san san
11-Sep-08 07:51 AM

I dont think its possible in VB.net also. I am not sure but i think we cant use function like this.

May be something is going wrong.

Can you paste the code where you found this.

Best Luck!!!!!!!!!!!!!
Sujit.

  solution

Perry replied to san san
11-Sep-08 07:53 AM

Hi,

Sometimes it is required based on your logic in the program. The FunctionReadData function must have returns some variable reference that will be used in the program in further steps. If you put the code for FunctionReadData and the some line after FunctionReadData = "Sucessfull" then I can tell you the exact things.

-Paresh

  That is the return result not the declaration

Minhajul Shaoun replied to san san
23-Sep-08 05:25 PM
Hello,
I am writing a code so that you can understand. Through this code we will determine whether a number is greater that 5 or not. We will pass number into the function. The function will return "Successfull" if our passed number is greater than 5.

'Code begins here
sub determine()
Dim str as string
str = determineresult(7)
msgbox (str)
end sub

Function determineresult (num1 as integer)
dim returnresult as string
if num1>5 then
returnresult="Successfull"
else
returnresult="Unsuccessfull"
End if
Retrun returnresult
End Function
'Code ends here

So, if the provided number is greater than 5 then the function will return a string value "Successfull". That value is not a function. That is only string variable. But it is rate to return string value from a function. The most common return value is Boolean.
Create New Account