i need some help... please help me convert this code into vb .net im using a device w/c is digital persona fingerprint scanner, the code works but it does not show any scanned image of the fingers in vb .net

Private Sub cmdCancel_Click()
    op.Cancel
    lblMessages.Caption = "Operation canceled"
    Set op = Nothing
End Sub

Private Sub cmdRun_Click()
    op.Run
    lblMessages.Caption = "Put your finger on the sensor"
    picSample.Picture = Nothing
    lblSampleID.Caption = ""
    lblEvents.Caption = ""
End Sub

Private Sub Form_Load()
    Set op = New FPGetSample
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Set op = Nothing
End Sub

Private Sub op_DevConnected()
    lblEvents.Caption = "Device connected"
End Sub

Private Sub op_DevDisconnected()
    lblEvents.Caption = "Device disconnected"
End Sub

Private Sub op_Done(ByVal pSample As Object)
    lblEvents.Caption = "Done"
    lblSampleID.Caption = pSample.InstanceID
    pSample.PictureOrientation = Or_Portrait
    pSample.PictureWidth = picSample.Width / Screen.TwipsPerPixelX
    pSample.PictureHeight = picSample.Height / Screen.TwipsPerPixelY
    picSample.Picture = pSample.Picture
End Sub

TwipsPerPixelX is not compatible in vb.net

Dani AI

Generated

Two quick causes to check (and a small, practical fix).

VB6 used twips for most form/control measurements; WinForms uses pixels, so you usually do not need Screen.TwipsPerPixelX in a migrated app — use the PictureBox Width/Height (pixels) directly when you set the scanner sample size. (learn.microsoft.com)

The fingerprint SDK you have is returning an OLE picture (IPicture/IPictureDisp). In VB.NET you must convert that COM picture to a System.Drawing.Image before assigning it to a PictureBox.Image. The easiest, reliable route is to use the AxHost helper that exposes GetPictureFromIPicture; create a tiny wrapper and call it from your op_Done handler, then assign the resulting Image to picSample.Image. Example (VB.NET):

' small AxHost wrapper to convert IPictureDisp -> System.Drawing.Image
Public Class PictureHelper
    Inherits System.Windows.Forms.AxHost
    Public Sub New()
        MyBase.New("{00000000-0000-0000-0000-000000000000}")
    End Sub
    Public Shared Function ImageFromIPicture(p As Object) As System.Drawing.Image
        Return CType(GetPictureFromIPicture(p), System.Drawing.Image)
    End Function
End Class

' in your callback:
Dim img As Image = PictureHelper.ImageFromIPicture(pSample.Picture)
If picSample.InvokeRequired Then
    picSample.BeginInvoke(Sub() picSample.Image = img)
Else
    picSample.Image = img
End If
pSample.PictureWidth = picSample.Width
pSample.PictureHeight = picSample.Height

Use the AxHost conversion because it handles IPictureDisp correctly. After you assign the image, set PictureWidth/Height in pixels (use picSample.Width/Height). (learn.microsoft.com)

One more important gotcha: device callbacks often run on background threads. Any update to WinForms controls must be marshaled to the UI thread (Invoke/BeginInvoke or equivalent) or you will see no image or get cross-thread errors. Also dispose previous Bitmaps if you replace them repeatedly to avoid memory leaks. (learn.microsoft.com)

For : Visual Studio 2010 does not include the old VB6 Upgrade Wizard — use VS2008 to run the built-in wizard first or consider a third‑party migration tool (ArtinSoft/Mobilize, etc.) or a manual port; the automatic wizard can only go so far and often leaves work to do. (learn.microsoft.com)

Notes: check the fingerprint vendor docs for a native .NET SDK (preferred), and if the COM picture conversion still fails test whether pSample.Picture is Nothing or an unsupported format before converting.

Recommended Answers

All 2 Replies

I need to convert a project from VB6 to VB.net. I downloaded Microsoft's Visual Studio 2010 Professional, which allegedly has a converter that would do that job. But, I can't find the converter anywhere. Does anyone know where I could find it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.