Page 1 of 1

Create and test for blank and null string. AND condition

Posted: Sat Jul 09, 2016 5:39 pm
by Mike L
What is the Basic code to create a blank string (say 10 bytes) and a null string ?
What is the code to test for either a blank or a null string ?

Also

I want an AND condition ... If A = 1 AND B = 2 etc....
How is this coded ?

Thanks in advance

Re: Create and test for blank and null string. AND condition

Posted: Tue Jul 26, 2016 12:02 am
by Cobramil
I do not know if I understand your question. Here are some basic tips.

Code: Select all

COLOR 7, 3: CLS
A$ = STRING$(10, 32) 'Defines string with 10 characters space
PRINT "String A$: "; A$; LEN(A$); "bytes, Code ="; ASC(MID$(A$, 1, 1))

B$ = STRING$(10, 88) 'Defines string with 10 characters X
PRINT "String B$: "; B$; LEN(B$); "bytes, Code ="; ASC(MID$(B$, 1, 1))

C$ = "" 'Defines null string
PRINT "String C$: "; C$; LEN(C$); "bytes, null string"

A = 1
B = 2
C = A + B

IF A = 1 AND B = 2 THEN PRINT "A = 1 and B = 2"
PRINT "A ="; A; " B ="; B; " C ="; C

IF A = B THEN
  PRINT "A is equal to B"
ELSE
  PRINT "A is not equal to B"
END IF

Re: Create and test for blank and null string. AND condition

Posted: Sat Aug 06, 2016 5:27 am
by EkriirkE
Just so you know, QB does not use null-terminated strings. So if you mean an empty string by "null string" then simply assign the value of "" to it:

Code: Select all

MyString$ = ""
If you're looking to create a "buffer", a quick way is the SPACE$() function

Code: Select all

MyString$ = SPACE$(10)
Your AND statement is perfectly valid the way you wrote it - just add a "THEN" at the end.