tags:

views:

59

answers:

1

how do i code this in vb.net:

focus the textbox and get the cursor to the rightmost digit?

+1  A: 

In a WindowsForm you can use:

Me.TextBox1.Focus()
Me.TextBox1.SelectionStart = TextBox1.Text.Length

In a WebForm you can set the focus using a javascript function like this:

function setCursorPosition(elemId, cursorPosition) {
    var element = document.getElementById(elemId);
    if(element != null) {
     if(element.selectionStart) {
      element.focus();
      element.setSelectionRange(cursorPosition, cursorPosition);
     }
     else
      element.focus();
    }
}
Gary.Ray