Register | Login | |||||
Main
| Memberlist
| Active users
| ACS
| Commons
| Calendar
| Online users Ranks | FAQ | Color Chart | Photo album | IRC Chat |
| |
0 user currently in Programming. | 3 guests |
Acmlm's Board - I2 Archive - Programming - Decimal To Hex? VB.. | | | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
User | Post | ||
elixirnova Red Paratroopa Level: 22 Posts: 29/177 EXP: 56507 For next: 1843 Since: 04-05-04 From: Midgar Since last post: 1 day Last activity: 1 day |
| ||
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) |
|||
neotransotaku Baby Mario 戻れたら、 誰も気が付く Level: 87 Posts: 1266/4016 EXP: 6220548 For next: 172226 Since: 03-15-04 From: Outside of Time/Space Since last post: 11 hours Last activity: 1 hour |
| ||
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 (edited by neotransotaku on 08-27-04 03:42 AM) |
|||
Squash Monster New Age Retro Hippie Togateiru Fohku Kohgeki!! GRUNGE no HAMSTER otona bite Peace love and turnpike! Level: 40 Posts: 336/677 EXP: 430507 For next: 10802 Since: 03-15-04 From: Maryland (of the Country Between Canada and Mexico) Since last post: 5 hours Last activity: 5 hours |
| ||
Hex(number) returns the hex version of a number as a string. It has a bit of trouble with negatives, though. | |||
neotransotaku Baby Mario 戻れたら、 誰も気が付く Level: 87 Posts: 1269/4016 EXP: 6220548 For next: 172226 Since: 03-15-04 From: Outside of Time/Space Since last post: 11 hours Last activity: 1 hour |
| ||
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. |
|||
interdpth Rex Level: 36 Posts: 233/527 EXP: 294398 For next: 13712 Since: 03-20-04 Since last post: 10 days Last activity: 31 days |
| ||
I just usually go dim mystring as string * 12 Seek #1, myoffset Get #1, ,mystring txtStringGoeshere = mystring close #1 |
|||
elixirnova Red Paratroopa Level: 22 Posts: 37/177 EXP: 56507 For next: 1843 Since: 04-05-04 From: Midgar Since last post: 1 day Last activity: 1 day |
| ||
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 |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
Acmlm's Board - I2 Archive - Programming - Decimal To Hex? VB.. | | | |