VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



String trimmer

by RyMon (1 Submission)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

Just a little snip of code that lets you trim a specified number of characters from either side of a string.

Inputs
Inputs are (in order): data to trim from, number of characters from left side, number of characters from right side
Code Returns
The new string, w/o trimmed characters

Rate String trimmer

Function trim_data(data As String, from_left As Integer, from_right As Integer) As String
  'If you try to trim to much, returns an empty string
  If Len(data) <= from_left + from_right Then
    trim_data = ""
  'If not, trim text from sides and return
  Else
    trim_data = Mid(data, from_left + 1, Len(data) - from_left - from_right)
  End If
End Function

Download this snippet    Add to My Saved Code

String trimmer Comments

No comments have been posted about String trimmer. Why not be the first to post a comment about String trimmer.

Post your comment

Subject:
Message:
0/1000 characters