Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - Decimal To Hex? VB..
  
User name:
Password:
Reply:
 

UserPost
elixirnova
Posts: 37/177
Hrm I got that part down pact with many diferent options and its VB.NET that im using now im back into the rom looking for some more levels
interdpth
Posts: 233/527
I just usually go

dim mystring as string * 12
Seek #1, myoffset
Get #1, ,mystring
txtStringGoeshere = mystring
close #1


neotransotaku
Posts: 1269/4016
Well, if he is reading from a file, then he will never run into a negative value except for end of file, which is typically -1.

As for negatives, it doesn't have trouble with it. It is more of people have trouble with it. Because if they put in -1 and get out 0xFFFF FFFF, that is expected because -1 in computer binary is 0xFFFF FFFF.
Squash Monster
Posts: 336/677
Hex(number) returns the hex version of a number as a string. It has a bit of trouble with negatives, though.
neotransotaku
Posts: 1266/4016
have you tried to take the decimal number and manually convert it to hex yourself?

like if the number is 255, divide first by 16 and you should get 15, which is F and then you take the remainder of what's left (which is 15) and divide by 16 again to get another f.

So, i guess in VB that would be something similar to the following:

Dim n as Integer
Dim upper as String
Dim lower as String
Dim readByte as String

n = readValue()
upper = n / 16
lower = upper mod 16

select case upper
case 10: upper = "a"
case 11: upper = "b"
case 12: upper = "c"
case 13: upper = "d"
case 14: upper = "e"
case 15: upper = "f"
end select

select case lower
case 10: lower = "a"
case 11: lower = "b"
case 12: lower = "c"
case 13: lower = "d"
case 14: lower = "e"
case 15: lower = "f"
end select

readByte = upper & lower

so, you can make the above code into a function that returns a hex string when given a integer number assuming it is between 0 and 255
elixirnova
Posts: 29/177
Im trying to store some bytes ive taken from a rom and store them into a string.. but they keep showing up as decimal and i want them to be hex....... any help? heres my code

Dim FileName As String = Application.StartupPath & "\rom.smc"
Dim FileNumber As Integer = FreeFile()
Dim RomData As Byte
Dim IntroText As Integer = &H31118

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim RomText As String
Dim i As Integer = 0
FileOpen(FileNumber, FileName, OpenMode.Binary, OpenAccess.Default)
While i <= 6
FileGet(FileNumber, RomData, IntroText)
RomText = RomText & RomData
IntroText = IntroText + 1
i = i + 1
End While
TextBox2.Text() = RomText
FileClose(FileNumber)
Acmlm's Board - I2 Archive - Programming - Decimal To Hex? VB..


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.003 seconds.