Hi,
I have a userform that enters a serial number in a style based on the format of the seerial on the unit.. so it might be 123-456 or 00000-00000 this is working fine and i have added an additional type, Only needs a letter B or S in front ie B-123456-1233445. If i wanted to add a letter to the start, what would i do to change the code. i have tried adding a letter to the code, missing something but not sure what. I just need either any letter or either S or B I have highlighted the lines i think i need to change in red.
cheers mark
Private Sub ComboBox1_Change()
If ComboBox1.Value = ("Transmission Unit LL") Then Me.TBserial = ("00000000000-00000000")
If ComboBox1.Value = ("Transmission Unit GPRS") Then Me.TBserial = ("00000000000-00000000")
If ComboBox1.Value = ("Base Unit") Then Me.TBserial = ("00000000000-00000000")
If ComboBox1.Value = ("Display Units") Then Me.TBserial = ("B-00000000000-00000000")
If ComboBox1.Value = ("ComBox PSTN") Then Me.TBserial = ("000-000-000000")
If ComboBox1.Value = ("ComBox GSM") Then Me.TBserial = ("000-000-000000")
If ComboBox1.Value = ("Dect Meter") Then Me.TBserial = ("000-000-000000")
Me.TBserial.SetFocus
Me.TBserial.SelStart = 0
End Sub
Private Sub TBserial_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Dim a As Integer
Select Case KeyCode
Case 48 To 57
a = TBserial.SelStart
Select Case ComboBox1.Value
Case "Transmission Unit LL", "Transmission Unit GPRS", "Base Unit"
If a = Len("00000000000-00000000") Then KeyCode = 0
Case "Display Units"
If a = Len("B-00000000000-00000000") Then KeyCode = 0
Case "ComBox PSTN", "ComBox GSM", "Dect Meter"
If a = Len("000-000-000000") Then KeyCode = 0
End Select
TBserial.Text = Left(TBserial.Text, a) & Chr(KeyCode) & Mid(TBserial.Text, a + 2)
a = a + 1
TBserial.SelStart = a
If Mid(TBserial.Text, a + 1, 1) = "-" Then
TBserial.SelStart = a + 1
End If
KeyCode = 0
Case 9, 10, 13
Case Else
KeyCode = 0
End Select
End Sub
Bookmarks