Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to insert new line character in VB

Status
Not open for further replies.

ubayeed

Programmer
Oct 9, 2002
2
0
0
US
I am new to VB programming,
My problem:
In my Text in a textbox, I want to insert a new-line character after a 'K' number of characters, K = integer.
how do I do that ?
 
Private Sub UserForm_Activate()
k = 13
mystr = "abcdefghijklmnopqrstuvwxyz"
mystr = Left(mystr, k) + Chr(10) + Right(mystr, Len(mystr) - k)
TextBox2.Text = mystr
End Sub

Will do it. The textbox multiline value must be true.
Chr(13) will do it as well.
 
In case you need more than 2 lines, this should work:

k = 5
Buffer = ""
TextBox1.MultiLine = True
intSegmentCnt = Int(Len(TextBox1.Text) / k)
For idx = 0 To intSegmentCnt
Buffer = Buffer & Mid(TextBox1.Text, idx * k + 1, k) & vbCr
Next idx
TextBox1.Text = Buffer
 
Hi,
Doubt in VB, Im new to VB

Problem:
I am inserting a Command button of name "LOAD" which should show the file names to be selected as we get in on open-Option ie CTRL+O in WINDOWS.
It would be highly appreciative If anyone can let me know the functions that are to be used for the above purpose. and also a sample program.

Thank you
 
check that the multiline paramter is true (at the textbox)
add "VBcrlf" to the string
enjoy
 
This opens the load dialogue box:

Sub Button1_Click()
filepath = Application.GetOpenFilename("Excel Files, *.xls")
MsgBox filepath
End Sub

And returns the path of the file selected
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top