Results 1 to 10 of 10

Thread: VBA-RapidOCR how can i changed to vb6?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    702

    VBA-RapidOCR how can i changed to vb6?

    dlelll ?

    thanks

    Because of the network block, I have an error downloading the file from github. Caused me to test unsuccessfully, now I download the full program test and there is no problem
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by xxdoc123; Apr 29th, 2024 at 11:08 PM.

  2. #2
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,383

    Talking Re: VBA-RapidOCR how can i changed to vb6?

    Quote Originally Posted by xxdoc123 View Post
    If VarType(P(i)) = vbString Then P(i) = StrConv(P(i), vbFromUnicode): V(i) = StrPtr(P(i))
    "vbFromUnicode" converts a string into a byte array so there is no "StrPtr" afterwards. Try an explicit byte array instead but if there are any Unicode characters in the string they will be lost when calling StrConv.

    Code:
    Dim ByteArray() As Byte
    If VarType(P(i)) = vbString Then
        ByteArray = StrConv(P(i), vbFromUnicode)
        VType(i) = vbLong
        VPtr(i) = VarPtr(ByteArray(0))
    End If

  3. #3
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,906

    Re: VBA-RapidOCR how can i changed to vb6?

    Quote Originally Posted by xxdoc123 View Post
    how can fixed

    https://github.com/DanysysTeam/VBA-RapidOCR

    i download this zip about ocr for vba

    but if run to this

    Code:
    'https://www.vbforums.com/showthread.php?789217-C-DLL-to-VB6&p=5505940&viewfull=1#post5505940 - Schmidt
    Private Function cdeclCallA(sDll As String, _
                                sFunc As String, _
                                ByVal RetType As VbVarType, _
                                ParamArray P() As Variant) As Variant
        Dim i As Long, pFunc As LongPtr, V() As Variant, HRes As Long
     
        V = P                                        'make a copy of the params, to prevent problems with VT_Byref-Members in the ParamArray
    
        For i = 0 To UBound(V)
    
            If VarType(P(i)) = vbString Then P(i) = StrConv(P(i), vbFromUnicode): V(i) = StrPtr(P(i))
            VType(i) = VarType(V(i))
            VPtr(i) = VarPtr(V(i))
        Next i
      
        pFunc = GetFuncPtr(sDll, sFunc)
        HRes = DispCallFunc(0, pFunc, CC_CDECL, RetType, i, VarPtr(VType(0)), VarPtr(VPtr(0)), cdeclCallA)
      
        For i = 0 To UBound(P)                       'back-conversion of the ANSI-String-Results
    
            If VarType(P(i)) = vbString Then P(i) = StrConv(P(i), vbUnicode)
        Next i
    
        If HRes Then Err.Raise HRes
    End Function
    Name:  crash.jpg
Views: 393
Size:  28.0 KB


    HTML Code:
        HRes = DispCallFunc(0, pFunc, CC_CDECL, RetType, i, VarPtr(VType(0)), VarPtr(VPtr(0)), cdeclCallA)  ----- crashed
    VBA-RapidOCR-main.zip

    thanks
    Best would be to ask in the github repo's Issues.

    cheers,
    </wqw>

  4. #4
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,444

    Re: VBA-RapidOCR how can i changed to vb6?

    Quote Originally Posted by wqweto View Post
    Best would be to ask in the github repo's Issues.
    Yep.

    I also don't think, that the issue is with the helper-function itself (cdeclCallA)...

    It might be more an issue with "feeding it the right, correct Params"
    (especially in its 64Bit-adaption within the VBA-Code-Project).

    @VanGoghGaming
    ... StrConv(..., vbFromUnicode) does not return a ByteArray-Type - but a normal BString-type instead (just filled with "non-wide" chars).

    Here is a code-line for your Immediate-Window:
    ?TypeName(StrConv("abc", vbFromUnicode))

    The fact that the below line works:
    ByteArray = <any BString, or BString-returning function>
    ... is due to another implicit conversion under the covers - backed by these APIs in all likelihood:
    https://learn.microsoft.com/en-us/pr...sion-functions

    Olaf
    Last edited by Schmidt; Apr 18th, 2024 at 12:23 PM.

  5. #5
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,383

    Question Re: VBA-RapidOCR how can i changed to vb6?

    Hmm yeah good one, I've only ever used "vbFromUnicode" in the context of byte arrays so it never occurred to me that another conversion was being done behind the scene. I've tried the functions you mentioned in that link:

    Code:
    Private Declare Function BstrFromVector Lib "oleaut32" (ByVal pSA As Long, ByVal pBSTR As Long) As Long
    Private Declare Function VectorFromBstr Lib "oleaut32" (ByVal pBSTR As Long, ppSA As Long) As Long
    BstrFromVector works fine as it is but I couldn't get VectorFromBstr to work. It does seem to return a valid SAFEARRAY pointer but the array is empty (cElements is zero). What am I missing there?

  6. #6
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,444

    Re: VBA-RapidOCR how can i changed to vb6?

    Quote Originally Posted by VanGoghGaming View Post
    Code:
    Private Declare Function BstrFromVector Lib "oleaut32" (ByVal pSA As Long, ByVal pBSTR As Long) As Long
    Private Declare Function VectorFromBstr Lib "oleaut32" (ByVal pBSTR As Long, ppSA As Long) As Long
    BstrFromVector works fine as it is but I couldn't get VectorFromBstr to work. It does seem to return a valid SAFEARRAY pointer but the array is empty (cElements is zero). What am I missing there?
    Probably "one level of dereferencing"...

    With the following, quite simple change in the Declare, I got it to work properly:
    Code:
    Private Declare Function VectorFromBstr Lib "oleaut32" (ByVal pBSTR As Long, B() As Byte) As Long
     
    Private Sub Form_Load()
      Dim B() As Byte
      Debug.Print VectorFromBstr(StrPtr(StrConv("abc", vbFromUnicode)), B)
      Debug.Print UBound(B), B(0), B(1), B(2)
    End Sub
    Olaf

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    702

    Re: VBA-RapidOCR how can i changed to vb6?

    Because I don't know the reason for the mistake. Perhaps there are significant differences between VBA and VB6. I hope to switch to running VB6?
    Last edited by xxdoc123; Apr 19th, 2024 at 02:45 AM.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    702

    Re: VBA-RapidOCR how can i changed to vb6?

    A lot of times I only have access to a limited amount of new knowledge about VB6 in this forum. I'm not very familiar with VBA.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    702

    Re: VBA-RapidOCR how can i changed to vb6?

    Because of the network block, I have an error downloading the file from github. Caused me to test unsuccessfully, now I download the full program test and there is no problem

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    702

    Re: VBA-RapidOCR how can i changed to vb6?

    Fortunately, this forum is not blocked. Long live freedom

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width