Qbasic function procedure

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators: Administrator, Global Moderator

Post Reply
suraj
Newbie
Posts: 1
Joined: Mon Nov 23, 2020 12:25 pm

Qbasic function procedure

Post by suraj »

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.
Peter Swinkels
Jr. Member
Posts: 19
Joined: Fri Sep 17, 2021 12:08 pm
Location: The Netherlands
Contact:

Re: Qbasic function procedure

Post by Peter Swinkels »

Your main issue is that you aren't assigning a value to be returned in your function:

Code: Select all

DECLARE FUNCTION Hello$()
PRINT Hello$
END

FUNCTION Hello$()
Text$ = "Hi, This is Suraj"
END FUNCTION

This results:
I modified your function to be of the type string ("$") and to return instead of print your text.
Post Reply