VB 6 String Handling


Earlier you learned about the string data type. The VB 6 language has many functions to handle string types. In this article, we will present the list of those functions with examples.

There are two types of strings in VB 6 programming.

  • Variable length strings
  • Fixed length strings

To declare variable length string you can use following syntax.

'variable length string declaration
Dim myStr as String  
'fixed length string declaration
Dim myFixedStr as String * 20

You can notice that we are using asterisk (*) to specify the length of the string which is 20 characters.

String Handling Functions in VB 6

String FunctionsDescription
StrComp()Compares two strings
StrConv()Convert strings
Format(), LCase, UCaseConvert A string to lowercase
or uppercase
Space(), String()Create strings
Len()Get the length of the string
FormatFormat a string
LSet, RSetJustify a string
InStr, Left, Mid, Right, Trim,
LTrim, RTrim
Manipulate strings
Option Comparestring comparison values
Asc, ChrUse ASC II and ANSI values
String Handling Functions

Visual Basic 6 For Dummies 1st Edition

Create your own custom Visual Basic programs fast for Windows 95, Windows 98, and Windows NT!

If you want to develop business applications for Windows, then Microsoft’s Visual Basic 6 programming environment is for you. With its powerful and friendly object-oriented interface, Visual Basic 6 is the ideal tool for creating easy-to-use and attractive interfaces of your own. Whether you want to build original programs from the ground up or take advantage of existing wizards, Visual Basic 6 For Dummies will help you design and debug your work – and accomplish all your goals!

  • Covers using Visual Basic 6 with Windows 95, Windows 98, and Windows NT
  • Walks you through the ins and outs of object-oriented programming in Visual Basic and using the Visual Basic toolset
  • Shows you how to make use of menus and submenus, write subprograms that everyone can share, save and retrieve information in databases, integrate ActiveX controls into your applications, and build attractive user interfaces with buttons, boxes, and scroll bars

From the fundamentals of writing BASIC code to the thrill of distributing your very own custom applications, Visual Basic 6 For Dummies brings a fresh perspective to programming in Visual Basic 6 that everyone can understand.