Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi How to Upgrade vb6 to vb.net code ???????
VB
========== Create ==========
    Private Const W As Long = 4
    Private Const H As Long = 4
    Private Row As Long, Col As Long
    Private vLeft As Integer, vTop As Integer
    Private Cols As Long, Rows  As Long
    Private indx As Long
'============================

Private Sub Create_matrix()

    picturebox1.ScaleMode = vbpixle
    
    picturebox1.AutoRedraw = True
    Rows = picturebox1.ScaleHeight \ (H - 1)
    Cols = picturebox1.ScaleWidth \ (W - 1)
    
    Home(0).Visible = True
    Home(0).FillStyle = 1

    vLeft = 0
    vTop = 0
    
    For i = 0 To Home.UBound
        On Error Resume Next
        Unload Home(i)
    Next
    
    For Row = 1 To Rows
        For Col = 1 To Cols
            indx = (Row - 1) * Cols + Col
            Load Home(indx)
            Home(indx).Move vLeft, vTop, W, H
            Home(indx).Visible = True
            vLeft = vLeft + W - 1
        Next
        vLeft = 0
        vTop = vTop + H - 1
        
        Label1.Caption = "[ " & Col & " , " & Row & " ]"

    Next
    
        For Index = 1 To Home.UBound
        Xx = Home(Index).Left + Home(Index).Width \ 2
        Yy = Home(Index).Top + Home(Index).Height \ 2
        If picturebox1.Point(Xx, Yy) <> Blank Then
            Home(Index).FillColor = picturebox1.Point(Xx, Yy)
        Else
            Home(Index).FillColor = Blank
        End If
    Next
End Sub


////////////////////////////////////////////////////////////////////////////////



Private Sub Label2_Click()

    Listbox1.Clear

    Dim X As Integer, Y As Integer
    Dim Index As Integer
    Dim Blank As Long

    Blank = picturebox1.Point(0, 0)
  
    For Index = 1 To Home.UBound
        X = Home(Index).Left + Home(Index).Width \ 2
        Y = Home(Index).Top + Home(Index).Height \ 2
        
        If picturebox1.Point(X, Y) <> Blank Then
            Listbox1.AddItem "[ " & X & " , " & Y & " ]"

        Else
            Text = Text & "0"
        End If
        
    Next
End Sub

///////////////////////////////////////////////////////////////////////

Private Sub ClearPicture_Click()
    picturebox1.Picture = LoadPicture("")
    Listbox1.Clear
End Sub

///////////////////////////////////////////////////////////////////////

Private Sub LoadPicture_Click()
 
    Dim strFileName As String
    
         With commondialogcontrol1

        .CancelError = True

        .Filter = "JPEG (*.jpg)|*.jpg"

        .DialogTitle = "Picture Search"

        .InitDir = "C:\"

        On Error GoTo NoFileOpened

        .ShowOpen

        strFileName = .FileName

        NoFileOpened:

        End With
    
   picturebox1.Picture = LoadPicture(strFileName)

End Sub
Posted
Updated 20-Jun-12 23:11pm
v3

look this article[^]
 
Share this answer
 
 
Share this answer
 
Thank you for your question.

I found a vb6 to vb.net translator provided by http://www.tradukki.com/[^]
and they provided this :

VB
'========== Create ==========
Private Const W As Long = 4
Private Const H As Long = 4
Private Row As Long
Private Col As Long
Private vLeft As Integer
Private vTop As Integer
Private Cols As Long
Private Rows As Long
'============================
Private indx As Long
Sub Create_matrix()

    'picturebox1.ScaleMode = vbpixle
    'picturebox1.AutoRedraw = True
    Rows = picturebox1.Height \ (H - 1)
    Cols = picturebox1.Width \ (W - 1)
    Home(0).Visible = True
    'Home(0).FillStyle = 1
    vLeft = 0
    vTop = 0
    For i = 0 To Home.Count
        On Error Resume Next
        'Unload Home(i)
        Me.Controls.Remove(Home(i))

    Next i

    For Row = 1 To Rows
        For Col = 1 To Cols
            indx = (Row - 1) * Cols + Col
            'Load Home(indx)
            Me.Controls.Add(Home(indx))
            Home(indx).Location = New Point(vLeft, vTop)
            Home(indx).Size = New Point(W, H)
            Home(indx).Visible = True
            vLeft = vLeft + W - 1

        Next Col

        vLeft = 0
        vTop = vTop + H - 1
        Label1.Text = "[" & Col & " ," & Row & " ]"

    Next Row

    For Index = 1 To Home.Count
        Xx = Home(Index).Left + Home(Index).Width / 2
        Yy = Home(Index).Top + Home(Index).Height / 2
        If GetPixel(picturebox1, Xx, Yy) <> Blank Then

            Home(Index).BackColor = GetPixel(picturebox1, Xx, Yy)

        Else

            Home(Index).BackColor = Blank

        End If

    Next Index


End Sub

Private Function GetPixel(ByVal picture As PictureBox, ByVal x As Integer, ByVal y As Integer)
    Dim bitmap As Bitmap = picture.Image
    Return bitmap.GetPixel(x, y)

End Function

'////////////////////////////////////////////////////////////////////////////
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
    Label2_Click()
End Sub
Sub Label2_Click()

    Listbox1.Items.Clear()
    Dim X As Integer
    Dim Y As Integer
    Dim Index As Integer
    Dim Blank As Color
    Blank = GetPixel(picturebox1, 0, 0)
    For Index = 1 To Home.Count
        X = Home(Index).Left + Home(Index).Width / 2
        Y = Home(Index).Top + Home(Index).Height / 2
        If GetPixel(picturebox1, X, Y) <> Blank Then

            Listbox1.Items.Add("[" & X & " ," & Y & " ]")

        Else

            Text = Text & "0"

        End If

    Next Index


End Sub
'///////////////////////////////////////////////////////////////////
Private Sub ClearPicture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearPicture.Click
    ClearPicture_Click()
End Sub
Sub ClearPicture_Click()

    picturebox1.Image = Nothing
    Listbox1.Items.Clear()

End Sub
'///////////////////////////////////////////////////////////////////
Private Sub LoadPicture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadPicture.Click
    LoadPicture_Click()
End Sub
Sub LoadPicture_Click()

    Dim strFileName As String
    With commondialogcontrol1

        '.CancelError = true
        .Filter = "JPEG (*.jpg)|*.jpg"
        .Title = "Picture Search"
        .InitialDirectory = "C:\"
        On Error GoTo NoFileOpened
        .ShowDialog()
        strFileName = .FileName
NoFileOpened:

    End With
    picturebox1.Image = New Bitmap(strFileName)

End Sub


Is it what you were looking for ?
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900