Tuesday, 2024-05-07, 1:44 AM

Welcome Guest | RSS

MainRegistrationLogin
Qbasic Home

Catalog categories
Qbasic Tutorial [31]

Rate my Site
Rate JPSor Site
Total of answers: 168

Main » Articles » Qbasic Tutorial

Chapter 27 - Qbasic Tutorial

STR$() and VAL()

Up to now, we've been using string variables to hold strings and number variables to hold numbers. What if we really need to do some math with numbers that are in a string variable? Or maybe we need to get some numbers into a string variable somehow. QBASIC provides the STR$() and VAL() functions to help us out.

STR$() will let us convert from a number to a string. Like this:

 A = 25 ' A can only hold numbers
PRINT A
B$ = STR$(A) ' Convert A to a string, store in B$
PRINT B$

VAL() will let us convert from a string to a number. Like this:

 A$ = "25" ' Can't do any math with a string variable
PRINT A$
B = VAL(A$) ' Convert A$ to a number, store in B
PRINT B

Converting Numbers

Need to cover CINT(), FIX(), INT(), CDBL(), CSNG(), CLNG()



Source: http://jpsor.ucoz.com
Category: Qbasic Tutorial | Added by: JPSor (2009-02-26) | Author: JPSor
Views: 4158 | Rating: 0.0/0 |
Login

Qbasic Clock

Search

Visit my Friends

Who's Online

Total online: 1
Guests: 1
Resgistered: 0


Copyright MyCorp © 2024