VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Centers Text in Msgbox, Listview, Form Caption, Ect.

by Emporer (4 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 9th November 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Centers Text in Msgbox, Listview, Form Caption, Ect.

API Declarations



*The MaxChars is what the text will be centered by, if the length of Text is 10 and the MaxChars is 30, then 10 spaces will be on each side of Text.

Rate Centers Text in Msgbox, Listview, Form Caption, Ect.



Public Function Center(Text As String, MaxChars As Integer) As String
 spcs = Int(Len(Text) / 2)
 cntr = Int(MaxChars / 2)
 ctr = Space(cntr - spcs) & Text & Space(cntr - spcs)
 Do Until Len(ctr) = MaxChars + 3
  ctr = " " & ctr
 Loop
 Center = ctr
End Function


Download this snippet    Add to My Saved Code

Centers Text in Msgbox, Listview, Form Caption, Ect. Comments

No comments have been posted about Centers Text in Msgbox, Listview, Form Caption, Ect.. Why not be the first to post a comment about Centers Text in Msgbox, Listview, Form Caption, Ect..

Post your comment

Subject:
Message:
0/1000 characters