VB and VBA Users Source Code: Copying fixed length strings
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Copying fixed length strings
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Thursday, January 04, 2001
Hits:
666
Category:
Visual Basic General
Article:
An example of how to parse fixed length strings using the LSet statement is given below. Description: "LSet Left aligns a string within a string variable, or copies a variable of one user-defined type to another variable of a different user-defined type" Code: Option Explicit Private Type tEmployee Name As String * 12 Age As String * 2 Department As String * 8 Grade As String * 9 End Type Private Type tBuffer Buff As String * 1024 End Type Sub LSetExample() Dim Buffer As tBuffer Dim Employee As tEmployee 'Copy the string into a buffer Buffer.Buff = "Andrew Baker29EquitiesExecutive" 'Copy the buffer into a fixed type LSet Employee = Buffer 'Output results Debug.Print "Name: " & Employee.Name Debug.Print "Department: " & Employee.Department Debug.Print "Grade: " & Employee.Grade Debug.Print "Age: " & Employee.Age End Sub
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder