Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to use a textbox to accept two different format value such as "1xxx-xxxxx" and "xxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxx" the code is accepting "1xxx-xxxxx" format already I need to include the second format:
Your help is highly appreciated.

VB
Public Sub ValidFormatNo As String, sFCd As String, DataBase As Myabase)
Dim sSelect As String
  Dim rsRecords As Object
  Dim sNo As String
  Dim eSave As SaveError

 On Error GoTo 0
  
  If Len(sFormatNo)= FORMATNOLGTH Then
    If Mid(sFormatNo, 5, 1) = "-" Then
      sSelect = "Select * from FORMATNO where acct = '" _
        & Mid(sFormatNo, 1, 4) & "'"

          On Error Resume Next
      Call DataBase.SelectSnapshot(rsRecords, sSelect)
      If Err.Number = 0 Then

       On Error GoTo 0
        sNo = Right(sChargeNo, Len(sChargeNo) - 5)
        Select Case rsRecords("rule").Value

        Case "".....
      End If
    End If
    End If
Posted
Updated 18-Jun-12 9:45am
v3
Comments
Sergey Alexandrovich Kryukov 18-Jun-12 15:25pm    
First, where is your question?
Any special reason to use VB6?
--SA
myClassic 18-Jun-12 15:36pm    
Thanks for your response, the question is that;

I am trying to use a textbox to accept two different value format such as "1xxx-xxxxx" and "1xxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxx" the code is accepting "1xxx-xxxxx" format already I need to include the second format.

I was the using VB6 because the program was written originally in VB6 I am just modifying it to allow integration with newer applications.
Thanks
ledtech3 18-Jun-12 17:47pm    
Can you just and an
Else If Len(sFormatNo)= FORMATNOLGTH2 then
If (the code to check like the other one)

1 solution

VB
If Len(sFormatNo)= FORMATNOLGTH Then
    If Mid(sFormatNo, 5, 1) = "-" Then
      sSelect = "Select * from FORMATNO where acct = '" _
        & Mid(sFormatNo, 1, 4) & "'"
 
          On Error Resume Next
      Call DataBase.SelectSnapshot(rsRecords, sSelect)
      If Err.Number = 0 Then
 
       On Error GoTo 0
        sNo = Right(sChargeNo, Len(sChargeNo) - 5)
        Select Case rsRecords("rule").Value
 
        Case "".....
      End If
    End If
  elseIf Len(sFormatNo)= FORMATNOLGTH2 then 'the length of ur other string

        If Mid(sFormatNo, 10, 1) = "-" then 
             'Do whatever you need
        end if 

end if
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900