VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Truncates a String to a given length adds ... if string exceeds given length

by Todd Wayman (8 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Wed 4th April 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Truncates a String to a given length adds ... if string exceeds given length

Rate Truncates a String to a given length adds ... if string exceeds given length



'* Generated using VB 3.0 ToolBar
'* Author: Todd Wayman
'* Date: Apr, 04, 2001
'* Program: WinFotocat
'* Version: 1.00
'* Copyright © 2001 Todd Wayman; All rights reserved.
'* Procedure Title: Truncate_String
' *************************************************************
'*
'* Disclaimer:
'*
'* This software is provided AS IS without warranty of any kind, either
'* express or implied. This includes without limitation the fitness for
'* a particular purpose or application and any warranties of merchantability.
'* The author shall not be liable for any damage, whether direct, indirect,
'* special, or consequential, arising from a failure of this software or
'* accompanying files to operate in a manner desired by the user. The author
'* shall not be liable for any damage to data or property which may be
'* caused directly or indirectly by the use of this program.
'* By using and/or installing this software YOU assume all responsibility.
'*
'* End Disclaimer
'*
'* Comments:
'* Truncates a String to a given size 
'* 
'* and adds "..." to the end
'* 
'* Symtax:  X = Truncate_String("My dog spot",6)
'* Retruns: X = My dog...
'* 
'* Good for long path names.
'* End Comment Block  *************************************

Function Truncate_String (Temp As String, Size As Integer) As String
If Len(Temp) >= Abs(Size - 3) Then
Truncate_String = Left$(Temp, Abs(Size - 3)) & "..."
Else
Truncate_String = Temp
End If
End Function


Download this snippet    Add to My Saved Code

Truncates a String to a given length adds ... if string exceeds given length Comments

No comments have been posted about Truncates a String to a given length adds ... if string exceeds given length. Why not be the first to post a comment about Truncates a String to a given length adds ... if string exceeds given length.

Post your comment

Subject:
Message:
0/1000 characters