Well, we have learnt that function always returns a value. So, always followed that. But, i am quite confuse how the following code works:
DECLARE FUNCTION Hello()
PRINT Hello
END
FUNCTION Hello()
PRINT "Hi, This is Suraj"
END FUNCTION
This results:
Hi, This is Suraj
0
Appreciate, your help.
Qbasic function procedure
Moderators:Administrator, Global Moderator
-
- Newbie
- Posts:8
- Joined:Fri Sep 17, 2021 12:08 pm
Re: Qbasic function procedure
Your main issue is that you aren't assigning a value to be returned in your function:
I modified your function to be of the type string ("$") and to return instead of print your text.
Code: Select all
DECLARE FUNCTION Hello$()
PRINT Hello$
END
FUNCTION Hello$()
Text$ = "Hi, This is Suraj"
END FUNCTION
This results: