Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 4, 1997

Trimmed to Fit

This piece of code trims long file names to fit into forms captions, text boxes, and other limited spaces. The code allows you to specify the number of characters a file name must be before it performs the trimming. For example, if the label can hold 50 characters, then you would type LongDirFix(nFile,50). It's as simple as that. Here's the code:
 
Function LongDirFix(Incomming As _
	String, Max As Integer) As String
Dim i As Integer, LblLen As Integer, StringLen As Integer
Dim TempString As String
TempString = Incomming
LblLen = Max
If Len(TempString) <= LblLen Then
	LongDirFix = TempString
	Exit Function
End If
LblLen = LblLen - 6
For i = Len(TempString) - LblLen To Len(TempString)
	If Mid$(TempString, i, 1) = "\" Then Exit For
Next
LongDirFix = Left$(TempString, 3) + _
	"..." + Right$(TempString, Len(TempString) - (i - 1))
End Function
Shafayat Kamal
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date