Koelho

Hi,

I want to do a program with a textbox and a button, when I press the button the Ibeam in the textbox goes do the next line, like we do when we press in the enter button.

How do I do that

Thanks



Re: Visual Basic Express Edition Textbox

nobugz

Drop a textbox and a button on a form and paste this code:

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With TextBox1
.Multiline = True
.ScrollBars = ScrollBars.Vertical
.Height = 130
.Text = "nobugz" + vbCrLf + "waz here"
.SelectionStart = 0
End With
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'--- Move to next line
With TextBox1
'--- Search for next line ending
Dim nxt As Integer = .Text.IndexOf(vbCrLf, .SelectionStart)
If nxt < 0 Then
'--- Not found, start adding empty lines
.Text += vbCrLf
.SelectionStart = .Text.Length
Else
'--- Got it, move to next line
.SelectionStart = nxt + vbCrLf.Length
End If
.Focus()
End With
End Sub
End Class