ช่วยแก้ปัญหา unable to cast object of type 'system.int32' to type 'system.array' ใน VB หน่อยครับ

กระทู้คำถาม
ผมได้เขียน vb ให้ Get Product key ของ Windows แต่ตอนนี้เกิด Error     unable to cast object of type 'system.int32' to type 'system.array'  ต้องแก้ไขอย่างไรครับ

Public Class Form1
    

    Public Function ShowMyKey(ByVal Path As String, ByVal Name As String) As String
        Dim A As Object = My.Computer.Registry.GetValue(Path, Name, 0)
        Dim B As String = ""
        Dim C As String = ""
        Dim D As Integer = 52
        Dim E As Integer = 67
        Dim F(24) As String
        Dim G As Integer = 29
        Dim H As Integer = 15
        Dim J(15) As String
        Dim K(30) As String
        Dim L As String = ""

        If A Is Nothing Then Return "No Value"

        Try
            For i As Integer = LBound(A) To UBound(A)
                B = B & " " & Hex(A(i))
            Next
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)

        End Try

        F(0) = "B" : F(1) = "C" : F(2) = "D" : F(3) = "F" : F(4) = "G" : F(5) = "H"
        F(6) = "J" : F(7) = "K" : F(8) = "M" : F(9) = "P" : F(10) = "Q" : F(11) = "R"
        F(12) = "T" : F(13) = "V" : F(14) = "W" : F(15) = "X" : F(16) = "Y"
        F(17) = "2" : F(18) = "3" : F(19) = "4" : F(20) = "6" : F(21) = "7"
        F(22) = "8" : F(23) = "9"

        Try
            For i = D To E
                J(i - D) = A(i)
                C = C & " " & Hex(J(i - D))

            Next
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try

        For i As Integer = G - 1 To 0 Step -1
            If ((i + 1) Mod 6) = 0 Then
                K(i) = "-"
                L = L & "-"
            Else
                Dim M As Integer = 0
                For N As Integer = (H - 1) To 0 Step 1
                    Dim O As Integer = ((M * 2 ^ 8) Or J(N)) ' This dim is not a zero but the letter O
                    J(N) = O \ 24 ' This is also the letter O
                    M = (O Mod 24) ' This is also the letter O

                Next
                K(i) = F(M)
                L = L & F(M)
            End If
        Next
        Return StrReverse(L)
    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        TextBox1.Text = ShowMyKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductId")
    End Sub

End Class


ต้องขอโทษด้วยที่ไม่สามารถ เอารูปให้โชว์ได้
แก้ไขข้อความเมื่อ
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่