Results 1 to 11 of 11

Thread: question: copy from and paste to original form

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2013
    Posts
    1,126

    question: copy from and paste to original form

    Good day. I have this form on Application A and it has picturebox and a textbox.

    Now I have another form on Application A which purpose is to read the picturebox texts and post it back to textbox on Form on application A.

    Guys I have no idea on this but I hope someone can give me assistance on how to resolve this.

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: question: copy from and paste to original form

    Just so I understand.....you have, on one form, a picturebox and a textbox. And on the second form, you probably have a commandbutton in whose click event you want to 'read' what is in the picturebox on form1 and paste the 'text' into the textbox on form1.
    If so, a couple of questions. Why a second form, why not just a command button on the first form?
    WHAT is in the picturebox? Is it an 'image' of some text?

  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: question: copy from and paste to original form

    If you use something like this to put text into your picturebox on form1, you can simply make the string variable global (in a module) and display it on form1 from form2. BUT, again, why use two forms?
    Code:
    Option Explicit
    Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
    Const DT_CENTER = &H1
    Const DT_WORDBREAK = &H10
    Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    Private Sub Form_Load()
        Dim rc As RECT, strText As String
        strText = "The quick brown fox jumps over the lazy dog."
        With Picture1
            .AutoRedraw = True
            .ScaleMode = vbPixels '3
            rc.Right = .ScaleWidth
            rc.Bottom = .ScaleHeight
            DrawText .hdc, strText, -1, rc, DT_WORDBREAK 'Or DT_CENTER
        End With
    End Sub
    In the above example, if you want to 'read' the text in the picturebox, simply do: text1.text = strText.

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: question: copy from and paste to original form

    Something tells me there's more to it... I think I know what's going on... but I want to hear more from the OP before deciding what to do or how to respond directly. I've seen these kinds of questions before.

    @codesearcher - not sure why you have two forms, but you'll might want to explain a little more about what it is you're trying to accomplish. Is the text you're trying to read part of the image that's in the picture box? Or is it the .Text property of the picturebox (which I'm not sure it has), is it text written to the picturebox using a technique like Sam showed? your description is vague and lacking certain details. Often the solution varies depending on the details of the situation. Sometimes people try to simplify the question and in the process get answers that end up not working because details were left out.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    May 2013
    Posts
    1,126

    Re: question: copy from and paste to original form

    its a transcription work. and I got this separate program that shows the document on jpg format but I need to convert that to text using OCR or something and paste it back to the textbox. I am thinking if is it possible with my separate program to get that document on jpg format and convert that to text and paste to its textbox.

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: question: copy from and paste to original form

    now I am glad I kept mums... because that's NOT what I thought was going on... so the bottom line is that you want to write your own OCR application... It's not something I know how to do, not some think I care to know how to do... but I do know it isn't easy or all that simple. Basically you're taking an image and scanning it's pixels for patterns and then attempting to recognize those patterns into text.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    May 2013
    Posts
    1,126

    Re: question: copy from and paste to original form

    techgnome, yes not just only an ocr but to scan an picturebox from another application and programmatically post the scanned text to the texbox of that application.

  8. #8
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: question: copy from and paste to original form

    Nor I......is this for reading CAPTCHA images? If so, doesn't belong on this forum.

  9. #9
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: question: copy from and paste to original form

    Quote Originally Posted by SamOscarBrown View Post
    Nor I......is this for reading CAPTCHA images? If so, doesn't belong on this forum.
    Did you miss post #5? That's what my original gut instinct was... not the case here though...

    Quote Originally Posted by codesearcher View Post
    techgnome, yes not just only an ocr but to scan an picturebox from another application and programmatically post the scanned text to the texbox of that application.
    That's what an OCR app does... it scans an image and translates it into a text document of some kind...

    And see? you simplified your question and left out the all important detail that the picture box and text box ARE IN A DIFFERENT APP... so that explains why the second form with a button.
    Personally I think it's more effort than it's worth, but it could also be because I'm not sure where to start on something like that... dealing with images is not my thing.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    May 2013
    Posts
    1,126

    Re: question: copy from and paste to original form

    ok I will not ask about coding for OCR.

    I would like to achieve now is how to post a record from my application textbox to another applicatio's textbox and send key ENTER on that textbox.
    Please kindly assist.

  11. #11
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: question: copy from and paste to original form

    There is a free OCR that works. I tried it the results were "readable" but you would need to loop through words (from dictionary) to fix some mistakes.

    Try this free OCR from google, tesseract-ocr-setup-3.02.02.exe

    Here is the maine page
    https://code.google.com/p/tesseract-ocr/

    Go to the ReadMe and it tells you how to use it (using command prompt) can be easy to execute a command prompt command from VB6.

    Running Tesseract
    Tesseract is a command-line program, so first open a terminal or command prompt. The command is used like this:

    tesseract imagename outputbase [-l lang] [-psm pagesegmode] [configfile...]
    So basic usage to do OCR on an image called 'myscan.png' and save the result to 'out.txt' would be:

    tesseract myscan.png out
    Or to do the same with German:

    tesseract myscan.png out -l deu
    It is a start I would think, instead of writing your own which requires you to learn picture files data (header/data). You also need to know matrix matching algorithm, optical letter comparing, and much more.

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