Page 1 of 1

VB6 - Understanding Basic String Operations Play with Words, Simple! Rate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=82690&amp;s=e1ab3e0b851e78b587431d436e4b6b79&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 Nikhil_07n

• The cheese stands alone..

Reputation: 50
• Posts: 2,489
• Joined: 09-January 09

Posted 25 January 2009 - 08:11 AM

The string Functions allows us to work with strings, as it's clear from their name.

1) Lcase and Ucase Functions

Explanation : Converts string to Lower and Upper case respectively.

Syntax :

```
LCase(String)

UCase(String)

```

Example :

```
Print Lcase("NiKhIl")

' The Output is : 'nikhil'

Print UCase("grEen")

' The Output is : 'GREEN'

```

2) Len Function

Explanation : Returns length of string, simple.

Syntax:

```
Len(String)

```

Example:

```
Print Len("Green Day")

'The Output is 9

```

3) Trim, Ltrim , Rtrim

(i) Trim - Removes Leading and trailing spaces.
(ii) Ltrim - Removes leading spaces.
(iii) Rtrim - Removes trailing spaces.

NOTE : all of these DO NOT effect spaces BETWEEN the words.

Syntax:

```
Ltrim(String)
Rtrim(String)
Trim(String)

```

Example:

```
Print Trim("   Beautiful Day	 ")

'Output is 'Beautiful Day'

Print Ltrim("   Beautiful Day   ")

'Output is 'Beautiful Day   '

Print Rtrim("   Beautiful Day   ")

'Output is '   Beautiful Day'

'IMP: Carefully notice the spaces in OUTPUTs.

```

4) Left And right functions:

Explanation : Extracts some no. of characters from LEFTMOST and RIGHTMOST portion of a string respectively.

Syntax:

```
Left(String, Number-Of-Chars)
RIght(String, Number-Of-Chars)

```

Example:

```
Print Left("The Offspring Rocks",5)

' Output is 'The O'

Print Right("The Offspring Rocks",4)

'Output is 'ocks'

```

5)Mid Function

Explanation : Extracts some character from ANY portion of the string.

Syntax:

```
MID(String, Start-Position, Number-Of-Chars)

```

Example:

```

' The Output is 'sk'

```

6) Instr Fuction

Explanation : THis function searches string within strings, i.e., returns location of a string within string.

Syntax :

```
Instr(start-postion, string-in-which-searchin, string-to-search-for)

```

Explanation :

```
Print InStr(1, "Brain Stew", "ain")

' The OutPut is 3

```

7) Space Function

Explanation : Produces Number of Spaces, easy.

Syntax:

```
Space(no-of-spaces-to-be-generated)

```

Example:

```
Print "Hi" & Space(5) & "There"

'Output is 'Hi	 There'

```

8) String Function

Explanation : Generate particular no of characters.

Syntax :

```
String(number-of-times, character)

```

Example :

```
Print String(10, "A")

'The Output is 'AAAAAAAAAA'

```

9) Str Function

Explanation : Converts a number in equivalent string.

Syntax:

```
Str(number)

```

Example :

```
Print Str(-155)

'Output is "-155"

```

10) Asc Function

Explanation : Returns Ascii code of a character.

Syntax:

```
Asc(String)

```

Example:

```
Asc("F")

'Output is 70

Asc("Dessloch")

'Output is 68 as ascii code of "D" is 68

'NOTE: In multi charactered string, it prints ascii code of first letter without any error

```

10) StrReverse Function

Explanation : Returns the string, INVERTED.

Syntax:

```
StrReverse(String)

```

Example:

```
StrReverse("ABCD")

'Output is 'DCBA'

```

=============END================

whoa, lots of Typing!

Is This A Good Question/Topic? 1

Replies To: VB6 - Understanding Basic String Operations

#2 The Gothic

Reputation: 0
• Posts: 20
• Joined: 04-June 09

Posted 08 June 2009 - 02:16 AM

Thx a lot, it´s very usefull for novice like me

This post has been edited by The Gothic: 08 June 2009 - 02:17 AM