SeStart question

  • Thread starter Thread starter NNlogistics
  • Start date Start date
N

NNlogistics

I have a text box that I want to format and then depending on another field,
start with a specific value and start the cursor right after.

So I choose a value on a combo box (M/C,Amex,visa or Discover) I choose M/C
so on input of the txtbox, I want it to start at the second character - in
this case after the 5. I tried several variations, this get me the closest
but the cursor starts before the 5?

Private Sub txtCCAccountNumber_Enter()
If Me.cmboCCType = "M/C" Then
Me.txtCCAccountNumber.InputMask = "0000\-0000\-0000\-0000"
Me.txtCCAccountNumber = "5"
Me.txtCCAccountNumber.SetFocus
Me.txtCCAccountNumber.SelStart = 2
 
NNlogistics said:
I have a text box that I want to format and then depending on another
field,
start with a specific value and start the cursor right after.

So I choose a value on a combo box (M/C,Amex,visa or Discover) I choose
M/C
so on input of the txtbox, I want it to start at the second character - in
this case after the 5. I tried several variations, this get me the
closest
but the cursor starts before the 5?

Private Sub txtCCAccountNumber_Enter()
If Me.cmboCCType = "M/C" Then
Me.txtCCAccountNumber.InputMask = "0000\-0000\-0000\-0000"
Me.txtCCAccountNumber = "5"
Me.txtCCAccountNumber.SetFocus
Me.txtCCAccountNumber.SelStart = 2


The SelStart property is 0-based (as the help file should have told you).
If you want the cursor to be positioned between the first and second
characters, use:

Me.txtCCAccountNumber.SelStart = 1
 
Back
Top