What does this mean?
What does this mean?
What does LTRIM$ , RTRIM$, and STR$ mean?
example...LEFT$(LTRIM$(RTRIM$(STR$(q))), 1)
What would that do?
example...LEFT$(LTRIM$(RTRIM$(STR$(q))), 1)
What would that do?
- {Nathan}
- Veteran
- Posts: 1169
- Joined: Thu Aug 19, 2004 6:08 pm
- Location: The wetlands of central Ohio, USA
- Contact:
QB's inline help is your friend. So is your teacher... mabye.
LTRIM cuts off all left spaces. RTRIM cuts off all right spaces EG
Would ouput "I have extra spaces!". As for STR$, I dunno off hand. You can look it up.
LTRIM cuts off all left spaces. RTRIM cuts off all right spaces EG
Code: Select all
PRINT LTRIM$(RTRIM$(" I have extra spaces! "));
Converts a variable into a string. Adds a leading space for signing (+/-)
Code: Select all
string$="Test "+LTRIM$(STR$(123))
PRINT string$
Except string is a reserved keyword and that code would never runKylemc wrote:Converts a variable into a string. Adds a leading space for signing (+/-)
Code: Select all
string$="Test "+LTRIM$(STR$(123)) PRINT string$
If you need music composed in MP3, WAV, or MIDI format, please contact me via email.
Xerol's Music - Updated Regularly!
Xerol's Music - Updated Regularly!
-
- Veteran
- Posts: 1055
- Joined: Sun Jan 02, 2005 2:11 pm
- Location: At my computer
- Contact:
Re: What does this mean?
LTRIM$ trims off wightspaces(or spaces) left of a string:Anonymous wrote:What does LTRIM$ , RTRIM$, and STR$ mean?
example...LEFT$(LTRIM$(RTRIM$(STR$(q))), 1)
What would that do?
Code: Select all
String = " Hello "
NewString = LTRIM$(String)
NewString = "Hello "
Code: Select all
NewString = " Hello"
Code: Select all
Var = 100
String = STR$(Var)
String = "100"
Code: Select all
q = 200
PRINT LEFT$(LTRIM$(RTRIM$(STR$(q))), 1)
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
(x.t.r.GRAPHICS)
Let me walk you through Ratt's example, step by step as it evaluates the statement.
1. It takes the STR$ of 200, which gives us a string of 4 characters, a space and 200.
2. Next it does the RTRIM$ which doesn't do anything because we have no trailing spaces. So we still have a space and 200.
3. Now it does the LTRIM$, which removes the leading space. We now have 3 characters, 200.
4. Now it does the LEFT$ on these 3 characters grabbing only the first character as specified by the ",1". So, the final result is 2.
It performs these functions in that order because, in the order of the parenthesis, each function needs a value or a string on which to operate. The STR$ goes first since it has the value of q to work with. Then the RTRIM$ works on the string result of the STR$, and so on.
*****
Code: Select all
q = 200
PRINT LEFT$(LTRIM$(RTRIM$(STR$(q))), 1)
2. Next it does the RTRIM$ which doesn't do anything because we have no trailing spaces. So we still have a space and 200.
3. Now it does the LTRIM$, which removes the leading space. We now have 3 characters, 200.
4. Now it does the LEFT$ on these 3 characters grabbing only the first character as specified by the ",1". So, the final result is 2.
It performs these functions in that order because, in the order of the parenthesis, each function needs a value or a string on which to operate. The STR$ goes first since it has the value of q to work with. Then the RTRIM$ works on the string result of the STR$, and so on.
*****
If you are ahead of me, lead.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.
-
- Veteran
- Posts: 1055
- Joined: Sun Jan 02, 2005 2:11 pm
- Location: At my computer
- Contact: