Results 1 to 4 of 4

Thread: What is a byte array?

  1. #1

    Thread Starter
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330

    What is a byte array?

    Hi,
    I'm working with some applications that require data to be passed as a byte array. I'm getting them to work without really understanding what's going on.
    Simply, what is a byte array and how is it different from simple binary data?
    Thanks,
    Al.
    A computer is a tool, not a toy.

  2. #2
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    all data in computers is binary, the question is how it is organized. Byte just means 8 bits (actually that's NOT what it means, but that useage is so pervasive in today's computer arena that you'll even find it in glossaries, so use it as a working definition). Integer means either 16 bits or 32 bits depending on the processor. Other data types organize bits into chunks of varying sizes from one bit to dozens of bits, that are organized and interpreted according to arbitrary, but perfectly useable, schemes.

  3. #3
    Lively Member bumbala's Avatar
    Join Date
    Sep 2002
    Posts
    111
    Byte variables are stored as single, unsigned, 8-bit (1-byte) numbers ranging in value from 0–255.

    The Bytedata type is useful for containing binary data.

    This is what it says in MSDN...

  4. #4
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692
    Here's an example of a byte in action:

    VB Code:
    1. Option Explicit
    2.  
    3. Dim GameWinner As Byte 'This is used to determine if we have a winner of a game is.
    4. Dim Rounds As Integer 'This is used to determine how many rounds have been played.
    5.  
    6. Private Sub DetermineGameWinner()
    7.     If txtPlayer1.Text > txtPlayer2.Text And txtPlayer1.Text > txtPlayer3.Text Then
    8.         GameWinner = 1 '1 indicates a win
    9.         MsgBox "Player 1 wins!"
    10.     ElseIf txtPlayer2.Text > txtPlayer1.Text And txtPlayer2.Text > txtPlayer3.Text Then
    11.         GameWinner = 1
    12.         MsgBox "Player 2 wins!"
    13.  
    14. 'Use ElseIf with txtPlayer3.Text also.
    15.     ElseIf txtPlayer1.Text = txtPlayer2.Text And txtPlayer1.Text = txtPlayer3.Text Then
    16.         GameWinner = 0 '0 indicates a tie.
    17.         MsgBox "The game is a draw."
    18.     End If
    19.  
    20. 'Put this whereever you need it.
    21. If Rounds = 10 Then
    22.     DetermineGameWinner
    23. End If
    24. End Sub

    Hope this helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width