586,080 active members*
3,651 visitors online*
Register for free
Login
Results 1 to 12 of 12
  1. #1
    Join Date
    Jun 2005
    Posts
    180

    Random Access

    I am trying to read the first xxx characters of a .bmp file into an array so I can get the header data. I have done this in VB6, but am having real time with the new lingo.

    Can anyone help?

  2. #2
    Join Date
    Apr 2005
    Posts
    3634
    Quote Originally Posted by rweatherly View Post
    I am trying to read the first xxx characters of a .bmp file into an array so I can get the header data. I have done this in VB6, but am having real time with the new lingo.

    Can anyone help?
    I assume you mean VB.NET?


    .

  3. #3
    Join Date
    Apr 2005
    Posts
    3634
    I'm not really sure what your asking?

    This works in VB.NET 2003. So it should work in 2005. (This is some code I wrote a while back, as an example only)


    Dim zzz1 As String
    Dim zzz2 As String

    zzz1 = Format(e.X, "##0.000")
    zzz2 = Format(e.Y, "##0.000")

    StatusBarPanel1.Text = (" X: " & zzz1 & " " & "Y: " & zzz2 & " " & "Z: 0.100")






    .

  4. #4
    Join Date
    Apr 2005
    Posts
    3634
    Are you looking for a decimal place?






    .

  5. #5
    Join Date
    Jun 2005
    Posts
    180
    Sorry, I must have been too vague with my problem. What I want to do is open a file for random access, and read from it. In VB6 (from what I remember) you would do this:

    dim a as string * 1
    open filename$ for random len =1
    recloc=100
    get 1, recloc, a

    The above would get the character at position 100 in the file.

    With VB Express (which I think is the same as vb.net) you have a differnet open statement and get statement. I have tried them, but I get a record length error.

    I was hoping someone had some sample code that worked.

  6. #6
    Join Date
    Apr 2005
    Posts
    3634
    Public Sub GetPixel_Example(e As PaintEventArgs)
    ' Create a Bitmap object from an image file.
    Dim myBitmap As New Bitmap("Grapes.jpg")
    ' Get the color of a pixel within myBitmap.
    Dim pixelColor As Color = myBitmap.GetPixel(50, 50)
    ' Fill a rectangle with pixelColor.
    Dim pixelBrush As New SolidBrush(pixelColor)
    e.Graphics.FillRectangle(pixelBrush, 0, 0, 100, 100)
    End Sub
    Link:
    http://msdn.microsoft.com/library/en...asp?frame=true

    Like the RGB color value? The code above gets the "X=50 & Y=50" location of a .jpg (just change to .bmp)

    I think that everything in .net has to be declared as a "New Bitmap" no matter what (GDI+ thing, going on)




    .

  7. #7
    Join Date
    Jun 2005
    Posts
    180
    Thanks for the input, but I should not have mentioned bitmap. My question is how to open and read from a random access file.

  8. #8
    Join Date
    Nov 2006
    Posts
    592
    I personally can't stand dot net.

    Sorry, just couldn't resist.

    I found AutoIT does what I want without all the random web searching it takes to find out how to do simple things.

    I'm sure it's just a mental limitation of mine, but nowhere could I find a concise description of the overall scheme of things. And I found examples of ten lines of code to do simple functions. After spending weeks playing with the language to write a simple routine I chucked the whole thing and went looking for another language.

    From now on, I will stay away from any software with the word "enterprise" anywhere on its website.

    End of rant, please disregard.

    --97T--

  9. #9
    Join Date
    Jun 2005
    Posts
    180
    97T-

    I agree with you. Maybe I am just not the organized type, but it has gotton so "structured" that it makes it difficult to do simple tasks. I realize that it also allows more felxability, but it makes it too difficult to learn and use for simple tasks.

  10. #10
    Join Date
    Feb 2007
    Posts
    7
    You may have already figured out your problem, but if it helps I had the same problems with some fills in VB6 and found that it was reading some of the data as on end of file code. I was able to open in binary and loop through till I got the data I needed.

  11. #11
    Join Date
    Feb 2007
    Posts
    12
    rweatherly- Did you figure out the code for file I/O? I have done this in VS '03, and can pull out some code if you still need it.

  12. #12
    Join Date
    Jun 2005
    Posts
    180
    rp74-

    Thanks -- I found several ways to do it. In the end I decided that I would just stick with doing it in Excel.

Posting Permissions

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