CoolRepresent string as intptr ?

Posts 1–4 of 4 · Page 1 of 1
Represent string as intptr ?
Hi
is there any way to represent this this value as intptr
Code:
Dim Pointer0 As String = "&H" + DataGridView1****ws(0).Cells("Column1").Value()
cuz this function --> FindAddress >> need it as intptr not as string

Code:
Dim Pointer0WithOffset As IntPtr = FindAddress(Pointer0)

--------
if i made it like that
Code:
Dim Pointer0 As Intptr = "&H" + DataGridView1****ws(0).Cells("Column1").Value()
it will not get the value of the cell > to get the value of the cell it must be --> Dim Pointer0 As String

thanks in advance
Code:
Dim Pointer0 As String = DataGridView1. Rows(0).Cells("Column1").Value()
Dim AddressInt As Integer
If Integer.TryParse(Pointer0, NumberStyles.HexNumber, Nothing, AddressInt) Then
    Dim ParsedAddress As New IntPtr(AddressInt)
    ' Do whatever with ParsedAddress
End If
Quote Originally Posted by master131 View Post
Code:
Dim Pointer0 As String = DataGridView1. Rows(0).Cells("Column1").Value()
Dim AddressInt As Integer
If Integer.TryParse(Pointer0, NumberStyles.HexNumber, Nothing, AddressInt) Then
    Dim ParsedAddress As New IntPtr(AddressInt)
    ' Do whatever with ParsedAddress
End If
Thanks i will try it
master131 method is exactly how i would have done it too.
You could make a little function so you don't need to paste that in every button
Code:
    Function Convert2IntPtr(ByVal ToConvert As String) As IntPtr
        Dim AddressInt As Integer
        Return If(Integer.TryParse(ToConvert, NumberStyles.HexNumber, Nothing, AddressInt), New IntPtr(AddressInt), IntPtr.Zero)
    End Function
So in your button all you would need to do
Code:
Dim Pointer0 As IntPtr = Convert2IntPtr(DataGridView1. Rows(0).Cells("Column1").Value())
And some error checking before you try writing to your address
Code:
        If Pointer0 <> IntPtr.Zero Then
            'Write hack
        End If
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?