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
Jul 30, 1997

Easy CR/LF Padding

When I write text in message boxes, labels, and so on, and I need to include a carriage return/line feed, I use this function, passing it the number of CR/LFs I need. This saves a lot of typing and looking up of ASCII values:
 
Sub cmdDelete_Click()

	msg = "Are you sure you want " & _
		"to delete this item?" & NL(2) & "Press OK"
	rc = MsgBox(msg, 4 + 32 + 256, "Confirm Delete")
	...
end sub

Function NL(num_lines As Integer) As String
'***************************************
'	This function returns a New Line 
'	character for the number of times 
'	passed to the function.
'***************************************

	Dim msg As String
	Dim i As Integer

	For i = 1 To num_lines
		msg = msg & Chr(13) & Chr(10)
	Next

	NL = msg
End Function
Bret Cutler
 
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