Results 1 to 5 of 5
  1. #1
    Milade8080 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    18

    Question Vba changes

    Hello dear friends
    The following Vba code that is related to Excel .How can I use this code in a text box Access.





    Code:
    Function checkMelliCode(Melli_Code As String) As Boolean
    
        Dim c@, n@, r@
    
        If Len(Melli_Code) < 10 Then Melli_Code = String(10 - Len(Melli_Code), "0") & Melli_Code
    
        If Melli_Code = "0000000000" Or _
          Melli_Code = "1111111111" Or _
          Melli_Code = "2222222222" Or _
          Melli_Code = "3333333333" Or _
          Melli_Code = "4444444444" Or _
          Melli_Code = "5555555555" Or _
          Melli_Code = "6666666666" Or _
          Melli_Code = "7777777777" Or _
          Melli_Code = "8888888888" Or _
          Melli_Code = "9999999999" Then
    
        Else
    
           c = Val(Mid$(Melli_Code, 10, 1))
       
           n = Val(Mid$(Melli_Code, 1, 1)) * 10 + _
             Val(Mid$(Melli_Code, 2, 1)) * 9 + _
             Val(Mid$(Melli_Code, 3, 1)) * 8 + _
             Val(Mid$(Melli_Code, 4, 1)) * 7 + _
             Val(Mid$(Melli_Code, 5, 1)) * 6 + _
             Val(Mid$(Melli_Code, 6, 1)) * 5 + _
             Val(Mid$(Melli_Code, 7, 1)) * 4 + _
             Val(Mid$(Melli_Code, 8, 1)) * 3 + _
             Val(Mid$(Melli_Code, 9, 1)) * 2
       
           r = n - Int(n / 11) * 11
       
           If (r = 0 And r = c) Or (r = 1 And c = 1) Or (r > 1 And c = 11 - r) Or (Len(Melli_Code) < 10) Then checkMelliCode = True
    
        End If
    
    End Function
    
    Private Sub Command1_Click()
    
        MsgBox checkMelliCode("4591246361")
    
    End Sub

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Would you tell us more about what you are wanting to do? I don't understand your question..

  3. #3
    Milade8080 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    18
    Quote Originally Posted by ssanfu View Post
    Would you tell us more about what you are wanting to do? I don't understand your question..







    For example, the following Access file, first open the form. If the number was typed in the field Melli_code algorithm above Visual Basic code to be followed. For example, 0849870356 or 0793420199 number of algorithm follows. And if the number is 6509874161 Type of algorithm does not follow. And warned that the number is not correct.


    Database1.zip

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Enter the number 0849870356 into the Melli_code text box.

    Then enter the number 6509874161 into the Melli_code text box.

    Is this what you want?
    Attached Files Attached Files

  5. #5
    Milade8080 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    18
    Quote Originally Posted by ssanfu View Post
    Enter the number 0849870356 into the Melli_code text box.

    Then enter the number 6509874161 into the Melli_code text box.

    Is this what you want?
    Super Thanks

Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums