-
Jul 7th, 2020, 05:34 PM
#1
Thread Starter
Member
Reading a single value?
Hi this code is used to read values from h592 to h595.
How can i write code to read only value h592, not from h592 to h595?
Code:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim b() As Byte = IO.File.ReadAllBytes("ecu test1.bin")
Label1.Text = ""
For i As Integer = &H592 To &H595
Label1.Text &= Chr(b(i))
Next
End Sub
Last edited by Shaggy Hiker; Jul 7th, 2020 at 05:39 PM.
-
Jul 7th, 2020, 05:41 PM
#2
Re: Reading a single value?
Well, think about it for a bit. As you have it, you have a loop. It first sets i to &H592, and gets the value from the array at location i. It then sets i to &H593, and gets the value from the array at location i. i has increased by one, but it is still getting the value from the array at location i. It then sets i to &H594 and gets the value from the array at location i, and so on until it reaches &H595.
So, if you want just one value. There's no need for a loop, just set i to the value you want.
My usual boring signature: Nothing
-
Jul 7th, 2020, 05:55 PM
#3
Thread Starter
Member
Re: Reading a single value?
I'm sorry but I really don't understand what am I supposed to do. I'm a beginner in VB, so if you can give me the edited code I would be very grateful!
-
Jul 7th, 2020, 09:04 PM
#4
Re: Reading a single value?
No, I'm just not going to do that. You've actually got all the code you need in the example you already posted. That's what makes the question so frustrating. You must not understand what you posted, because it has the answer in it already, so where did you get that? If this is homework, you won't be learning anything. If it's not homework, then you need to start with the basics, because YOU gave the answer to your question, and yet you ask me for it.
My usual boring signature: Nothing
-
Jul 8th, 2020, 12:44 AM
#5
Lively Member
Re: Reading a single value?
Live Demo
Module loops
Sub Main()
Dim a As Byte
' for loop execution
For a = 10 To 20
Console.WriteLine("value of a: {0}", a)
Next
Console.ReadLine()
End Sub
End Module
-
Jul 8th, 2020, 01:05 AM
#6
Re: Reading a single value?
For the record, there's no such thing as h592. The VB representation of a hexadecimal literal SPECIFICALLY uses the &H prefix, so only &H592 is actually meaningful. C-based languages, e.g. C#, use the mathematical standard for representing hexadecimal numbers, so 0x592 is also meaningful.
Last edited by jmcilhinney; Jul 8th, 2020 at 07:24 AM.
-
Jul 8th, 2020, 07:21 AM
#7
Re: Reading a single value?
Originally Posted by vargaperformance
Hi this code is used to read values from h592 to h595.
How can i write code to read only value h592, not from h592 to h595?
Code:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim b() As Byte = IO.File.ReadAllBytes("ecu test1.bin")
Label1.Text = ""
For i As Integer = &H592 To &H595
Label1.Text &= Chr(b(i))
Next
End Sub
Interesting this code, it is passel's one... as an answer to the same question you asked in an other thread of yours.... http://www.vbforums.com/showthread.p...=1#post5485953
The best friend of any programmer is a search engine
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|