Results 1 to 2 of 2
  1. #1
    toqilula is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    5

    Post Need help in VBA programming (java translation)

    Hello VBA lovers



    I Have wrote a simple code in java and i would very much like to be able to use it in ms access.
    Could someone translate it in vba please.
    I know it will be easy for most of the ppeople programming in VBA, cose it has only two loopes and some string variables.
    So I would really much appreciate if you can help me.
    here is the code writen i java:
    Code:
    Public class mod36 { Public static void main (String [] arg){ String _sIn = "GYM014650000005"; String sCharPool = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; String[] sArrayIn = New String [15]; char c; For (int i = 0; i < 15; i++){ c = _sIn.charAt(i); sArrayIn[i] = Character.toString(c); } int iSum = 0; For (int iCount = 0; iCount < 15; iCount++) { iSum = iSum + sCharPool.indexOf(sArrayIn[iCount].toUpperCase()) * (16 - iCount); } int iCtrl = iSum % 36; System.out.println ("rez: " + _sIn + sCharPool.substring(iCtrl, iCtrl + 1)); }}

  2. #2
    toqilula is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    5

    Thumbs up Java to vba

    finally the solution. Hope someone else find it useful

    Code:
    Dim ssIn As String: ssIn = "GYM019680000005"
    Dim sCharPool As String: sCharPool = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    Dim i As Long, iCtrl As Long
    Dim iSum As Long: iSum = 0
     
        For i = 1 To 15
           iSum = iSum + (InStr(sCharPool, Mid(ssIn, i, 1)) - 1) * (16 - (i - 1))
        Next i
     
        iCtrl = (iSum Mod 36)
     
        MsgBox "" & ssIn & Mid$(sCharPool, (iCtrl + 1), 1)

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

Similar Threads

  1. Programming
    By JLT in forum Programming
    Replies: 10
    Last Post: 04-14-2011, 10:07 AM
  2. Most likely a programming thing
    By dfelock in forum Programming
    Replies: 7
    Last Post: 12-21-2010, 11:10 AM
  3. Exception When Executing In Java But Runs In MS Access DB Manually
    By vasuresh.kishor@gmail.com in forum Access
    Replies: 0
    Last Post: 03-11-2010, 12:22 AM
  4. Replies: 0
    Last Post: 11-14-2009, 07:37 AM
  5. VB Programming
    By mstefansen in forum Programming
    Replies: 4
    Last Post: 08-31-2009, 07:15 AM

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