Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String Lenght

Status
Not open for further replies.

HebieBug

Programmer
Jan 8, 2001
354
JP
Am working on a mini program component that takes certain data and places it into a direct debiting system.
The Direct debiting system will only accept certain character lengths. Anyone know of an easy way of setting a variable to accept a maximum character lenght from another variable?
 
Right justified?
Code:
Function RJust(byval strToJustify as string, _
    byval strLeftPad as string, _
    byval lngLength as long) as string
    ' Pad max on left and take from the Right
    RJust = Right$(String$(lngLength,Left$(strLeftPad,1)) & _
            strToJustify, lngLength)
End Function
 
Hmmm.
How about creating a class with properties for each variable. In each Let Property, use Left$() in the asignment statement to the internal variable. When you later go to read it via the Get Property, it'll be the correct length. Think of this class as acting as a data filter.
[tt]
Option Explicit

Private m_FName As String
Private m_LName As String

Public Property Let FName(ByVal RHS As String)
m_FName = Left$(RHS, 20)
End Property
Public Property Get FName As String
FName = m_FName
End Property

Public Property Let LName(ByVal RHS As String)
m_LName = Left$(RHS, 30)
End Property
Public Property Get LName As String
LName = m_LName
End Property
[/tt]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top