rfresh Well-Known Member Licensed User Longtime User Feb 29, 2012 #1 I've seen B4A Constants written like this: Code: Copy 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...
I've seen B4A Constants written like this: Code: Copy 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...
NJDude Expert Licensed User Longtime User Feb 29, 2012 #2 Check THIS not sure if it's explained somewhere in that post. Upvote 0
rfresh Well-Known Member Licensed User Longtime User Feb 29, 2012 #3 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
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?
nfordbscndrd Well-Known Member Licensed User Longtime User Feb 29, 2012 #4 rfresh said: 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? Click to expand... 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: Feb 29, 2012 Upvote 0
rfresh said: 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? Click to expand... 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.
rfresh Well-Known Member Licensed User Longtime User Mar 1, 2012 #5 Ok so that means for B4A we just declare like this: Code: Copy CRLF = Chr$(10) ...if we don't need vb6? Upvote 0
Ok so that means for B4A we just declare like this: Code: Copy CRLF = Chr$(10) ...if we don't need vb6?
nfordbscndrd Well-Known Member Licensed User Longtime User Mar 1, 2012 #6 rfresh said: Ok so that means for B4A we just declare like this: Code: Copy CRLF = Chr$(10) ...if we don't need vb6? Click to expand... 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" Click to expand... Upvote 0
rfresh said: Ok so that means for B4A we just declare like this: Code: Copy CRLF = Chr$(10) ...if we don't need vb6? Click to expand... 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" Click to expand...
rfresh Well-Known Member Licensed User Longtime User Mar 1, 2012 #7 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
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.
JonPM Well-Known Member Licensed User Longtime User Mar 1, 2012 #8 You have to dim it like other variables Upvote 0
rfresh Well-Known Member Licensed User Longtime User Mar 1, 2012 #9 JonPM said: You have to dim it like other variables Click to expand... Nope: Code: Copy Dim DEFAULT_BUTTON = 50 The name remains in red and won't compile. Upvote 0
JonPM said: You have to dim it like other variables Click to expand... Nope: Code: Copy Dim DEFAULT_BUTTON = 50 The name remains in red and won't compile.
NJDude Expert Licensed User Longtime User Mar 1, 2012 #10 The right way to DIM is like this: Code: Copy Dim DEFAULT_BUTTON As Int DEFAULT_BUTTON = 50 You better read the Beginner's Guide Upvote 0
The right way to DIM is like this: Code: Copy Dim DEFAULT_BUTTON As Int DEFAULT_BUTTON = 50 You better read the Beginner's Guide
rfresh Well-Known Member Licensed User Longtime User Mar 1, 2012 #11 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
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.
nfordbscndrd Well-Known Member Licensed User Longtime User Mar 1, 2012 #12 rfresh said: 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. Click to expand... 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 said: 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. Click to expand... 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.
rfresh Well-Known Member Licensed User Longtime User Mar 1, 2012 #13 Thanks, so that answers my question. Your naming suggestion is a good one when I need to create a B4A 'Constant'. Upvote 0
Thanks, so that answers my question. Your naming suggestion is a good one when I need to create a B4A 'Constant'.