Vb.net 聚焦最右边的文本框

Vb.net 聚焦最右边的文本框,vb.net,Vb.net,如何在vb.net中编写此代码: 聚焦文本框并将光标移到最右边的数字?在Windows窗体中,您可以使用: Me.TextBox1.Focus() Me.TextBox1.SelectionStart = TextBox1.Text.Length 在Web表单中,您可以使用如下javascript函数设置焦点: function setCursorPosition(elemId, cursorPosition) { var element = document.getElementBy

如何在vb.net中编写此代码:


聚焦文本框并将光标移到最右边的数字?

在Windows窗体中,您可以使用:

Me.TextBox1.Focus()
Me.TextBox1.SelectionStart = TextBox1.Text.Length
在Web表单中,您可以使用如下javascript函数设置焦点:

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