Constants Help

rfresh

Well-Known Member
Licensed User
Longtime User
I've seen B4A Constants written like this:

B4X:
vbCRLF CRLF = Chr(10)

...but I can't find anything that explains what vbCRLF and CRLF are? I'm not used to seeing two definations when defining a Constant. Why does B4A have two?

Thanks...
 

rfresh

Well-Known Member
Licensed User
Longtime User
It has this (which I've seend before)

Constants:---------
"" Quote = Chr$(34)
vbCr CRLF = Chr$(10)
vbCrLf none

but doesn't explain why we have a cbCr and a CRLF on one line to define a consant. Which one do you use? The vbCR or the CRLF? Or either?
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
It has this (which I've seend before)

Constants:---------
"" Quote = Chr$(34)
vbCr CRLF = Chr$(10)
vbCrLf none

but doesn't explain why we have a cbCr and a CRLF on one line to define a consant. Which one do you use? The vbCR or the CRLF? Or either?

The document in that post shows, as explained in the post, the B4A equivalents of some VB6 (Visual Basic 6) functions. The VB6 code is in the left column and the B4A column is on the right, so the vbCR is VB6 code and CRLF is B4A, etc.
 
Last edited:
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Ok so that means for B4A we just declare like this:

B4X:
CRLF = Chr$(10)

...if we don't need vb6?
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
Ok so that means for B4A we just declare like this:

B4X:
CRLF = Chr$(10)

...if we don't need vb6?

You don't need to declare CRLF. It is a "constant", which means that its value is already set as "carriage return, line feed".

You don't *need* vb6 for coding B4A. The chart you referred to is to aid VB6 programmers (for Windows) who are learning B4A. The chart converts VB6 code (or functions) to B4A code/functions. If you are not a VB6 programmer, you don't need the chart since you would not care about converting VB6 to B4A.

As for CRLF, here is an example:

Label.Text = "Line 1" & CRLF & "Line 2"
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Ok so CFLF is already pre-declared but what about Constants that are custom to my app?

DEFAULT_BUTTON = 1

If I wanted to use the above constant, how would I declare it?

It shows up in red in the IDE and won't compile.
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
That's not a Constant because I can change it's value. It's just a normal variable. Constants (in other languages) cannot be changed.

If that is how B4A implements 'Constants' then it's not really a constant.

But thanks very much for your help.
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
That's not a Constant because I can change it's value. It's just a normal variable. Constants (in other languages) cannot be changed.

If that is how B4A implements 'Constants' then it's not really a constant.

You are correct that while B4A has some built-in constants, such as CRLF, B4A does not support user-defined constants.

You might want to precede names of variables which you don't want changed with "cons", such as --

Dim consInt_SomeName1 As Int
Dim consStr_SomeName2 As String
etc.
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Thanks, so that answers my question. Your naming suggestion is a good one when I need to create a B4A 'Constant'.
 
Upvote 0
Top