Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Read Specific Bytes At An Offset


I need to read a few bytes at a specific offset, say for example the first 10 bytes of the file. I also need to write to a specific offset... This is for patching a file.

Example of what i need this information for:
(function breakdown)
Check for file -> Check File Size -> Check Bytes* -> Check if file is writable -> Write Log

I appreciate any posts to help me out here, sorry if this is a newbie question. Im not that educated with VB File I/O.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Read Offset Bytes
New to the forum Hi All!

Can someone help me with the following. I need to read a 16 byte address from a hex file to a textbox from an offset 03FFCE0.
When I try I just get this ÿŽ:íjêöê$ÿÿÿÿW rather than the highlighted below.

Thanks in advance!

Reading Bytes From Binary File At Set Offset
Title says it all.
I want to read a certain number of bytes from a binary file, at a certain offset.

I tried input() but I can only get it to read from the beginning of the file. I also tried Get #1...bla..bla... but got nothing at all.

I am new to Visual Basic. I know how to do this all with PHP, but as you all know, it is completely different with VB.

If this topic has already been covered, then I apologize, but I couldn't find anything by searching.

Any help is much appreciated.

Reading Specific # Of Bytes From Com
Hello All,

I need to read 30400 (30K) bytes from the com port, these bytes are sent in a sequence byte by byte, how do I set the InputLen property? Do I set it to 1 and make a loop in the OnComm event to receive each byte (too slow) or can I read them all at once?

Thank you in advance

Reading/Writing Specific Bytes
i am sending files across the network using thee winsock control but i don't know how to open a file and read a certain amounts of bytes from it and and write a certain amount of bytes to it. can some please give me a link or explain. thanks.

Reading Specific Bytes In A File...
okay... i know how to open a file and read various pieces of info out of it... but only if it's comma delimited.

i want to grab information from within a jpeg file where the data is stored with "tags"? i think this means at specific bytes, but i could be wrong. i downloaded a document that tells me all the tag numbers, does anyone know how i read the data that's there?

i can post a snippet of the doc if necessary...

thanks

col.

Reduce The Size In Bytes Of A Specific Image
I use a picturebox and load into it a jpeg image of 568 bytes. If I save the image from the picturebox programmatically using savepicture method, then it generates a bmp of 1315 bytes.
I tried to reduce the size (in bytes) of the initial image from 568 bytes to 102 bytes. I loaded the new file on the picturebox and then saved it again as bmp. The result was the same! It generated a bmp file of 1315 bytes again!!! So, I see that the file size depends not on the quality of the initial image but only on the canvas size. Right?
Question: Can I reduce the size of the bmp file? (even if I have to loose in quality, I don't mind).

Michael Vlastos
Automation Engineer
Intracom, Research & Development Division
Development Programmes Department
Athens, Greece

How To Read A Specific Http Link On A Specific Page And..
Hello ppl!
I am a REAL newbie to VB and I am trying to do a simple thing (I hope) I have no real basecode just the one to open a specific link: Code:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Form_Load()

    ShellExecute 0, vbNullString, "http://play.mp3.com/cgi-bin/play/play.cgi/AAIBQgAAAADABG5vcm1QBAAAAFLeTgEAUQoAAABYAQAAAFneTgEAQ2.J0TwUhHw6YJu97A3gU7XcOVum/fuzytoes.m3u/", vbNullString, vbNullString, vbNormalFocus
Unload Me

End Sub
Now, Id like to add some functionality since MP3.com changes the links every now and then. I need the program to go to the page, snatch the new link and then use it to open, say winamp. BTW, IE 5.5 does not alway's respond to the code above.. Dunno why. Sometimes it does. sometimes nothing happends whatsoever. Strange!

Ideas? Perhaps not a whole solution cause then I'll not learn. Thanx in advance! /FuzyToes

Read Memory... 12 Bytes??
Hey,

I need help reading memory. First I get my pointer at &H7e49c0. Everything is fine here. Then using my pointer, how do I do to define the type/struct/whatever, consisting of 3 float values x, y and z. Then I must read the memory: (size: 3*4=12)

Thx,
JP

Best Way 2 Read Bytes In A File
what is the best way to return a string from a file between the 308 and the 400th byte in a file?

- is there a better way than getting each line then appending them and using mid?

thanks Kris

IO Read/Write Bytes
is there any way to monitor IO Read/Write bytes, like in Win2000 taskman?

Read The 2 Bytes Of A 16 Bit Word
I need to read seperately, a word's (16 bits data type) 2 bytes. Lets suppose the variable for word is varWord.

TIA
Olcay

 

Read Pixels In Bytes
I have a picture on a picture box.
I need to read or get every byte of the picture.
One pixel consists of 3 bytes(24 bits). I need to get byte by byte.
The GetPixel function only gets the pixel value which consists of 3 bytes or less.

Please help me.
Dev.

How To Read/write Bytes From And To A File?
hello,

I want to read bytes from a file and write bytes to a file...
the thing is, I want to point on a certain byte position and read it...

how can I do that in vb?

thanks

How To Read 2 Bytes Of Binary Data
Hi!
Hope someone knows this.
I have file that consists of binary data. The file has a field of data values that spans 2 bytes long. I am trying to read in the 2 bytes of data into a variable to retrieve the data back in decimal value. However, i only have integer and byte datatypes. I thought Vb allowed the short datatype but i was not able to use it.
Would anyone know how i can read multibyte binary data?

Any ideas would be helpful. Thanks.

Read Cda Files (not The 44 Bytes Crap)
is this an API call?

Does the MM control can help?

is there sample code ou there about it?

I guess I need to learn how to read itwise a CD?

How can we do that?

I know, fellas that at download.com, there are

plenty of freeware and shareware but I just want to do it.

thank you for any tip and happy holidays for my VBroSists !

( for VB-brothers-Sisters ...sound like a electric toy I have never used (yet).

Read Bytes From Binary Files
Hi all,
I need to read bytes 335-344 and 390-400 from a binary files and print them out.

Can someone please tell me how to read those bytes.

Thanks

Ed


Read Real Type (6-bytes) In A Binary Files
Hi everyone,

I need your help.

I'm trying to read a binary file written in Pascal. I want to read a real type (6-bytes) with VB6 but I can't figure out how.

Please someone help me

Bruno

How To Read Bytes In Binary Mode Inserting In Matrix
After i've tried to update a vb 6.0 project to vb.net, using visual studio utility,i can't read correctly data bytes from a .bmp file to insert them in a matrix to operate on.

Using vb 6.0 the code was based on Get function:

GET #1, PIXELSTART, PHOTO.MATRIX

where PHOTO is a structure data type, with a member MATRIX previously defined in this way:

ReDim PHOTO.MATRIX(1 TO PHOTO.WIDTH*3,1 TO PHOTO.HEIGHT)

in this way,the program read bytes starting from PIXELSTART in bmp file  and put them in transpose matrix resultant.
For example:
an image of 622*277 pixel has a matrix of 1868*277 bytes considering 24 bit depth and so 3 bytes per pixel.

With Get function the bidimensional array,the matrix, was filled correctly, as visible using debugger, with the single pixel value of the bitmap.

Using vb.net, the utility tansformed the code in this way:

ReDim PHOTO.MATRIX(PHOTO.WIDTH*3,PHOTO.HEIGHT)

FILEGET(1,PHOTO.MATRIX(PHOTO.WIDTH*3,PHOTO.HEIGHT),STARTPIXEL)

I know the fact that the array in enumerated in different ways in vb 6.0 and .net(start with 0 in net,with 1 in 6.0), but the big big problem is that THE MATRIX HERE IS FILLED WITH NOTHING!!!Every matrix value is equal to zero, and it result in a black image!
The dimensions of the bitmap however are read correctly from bmp file in this way:

FILEGET(1,WIDTH,19)

FILEGET(1,HEIGHT,23)

Some help please!!!






Con la funzione Get tutto filava liscio e l'array bidimensionale veniva
riempito correttamente come visibile dal debug con i valori dei singoli
pixel della bitmap.
Con l'upgrade a .Net il codice è stato così trasformato:

   ReDim FOTO.MATRICE(FOTO.LARGHEZZA*3, FOTO.ALTEZZA)

                    FileGet(1, .g(FOTO.LARGHEZZA*3, FOTO.ALTEZZA),
INIZIOPIXEL)

Tralasciando il fatto che l'array è indicizzato diversamente dal 6.0 cioè
qui parte da ZERO e non da UNO, il problema è che nell'array non viene messo
alcun valore letto dal file numero 1, ovvero il valore di tutti gli elementi
della matrice e per ognuno = 0, risultato si ottiene una bitmap delle
dimensioni giuste,viste che precedentemente questi bytes vengono letti
correttamente sempre usando FileGet,ma tutta nera!
le dimensioni sono state correttamente recuperate:

                    FileGet(1, LARGHEZZA, 19) 'Width

                    FileGet(1, ALTEZZA, 23) 'Height
Qualcuno ha un'idea?


Read/Send Bytes/words Through Hardware Ports
I have been using QBasic's INP port% and OUT port%, num% commands to read and send bytes through hardware ports. Now, these are not available in Visual Basic. Can anyone help me with this. I have to use some of QBasic subs in Visual Basic.
Somebody told me to use the C functions: inport(), outport(), and make a windows DLL. I tried it using Borland C 3.1. it worked fine in VB 3, but not with 32-bit versions of VB. Now what can I do to tackle this problem.
Please note that the ports are not the common serial or parallel ports.

Read Specific Line
Can someone tell me how to read the line that start with "03" in a file?
Thks in advance

Read Specific Line
Hi,
In my current project I need to load ever first and every fifth text line (from a txt file for example) to 2 textboxes

However the current code I use only allows me to but all the 10 lines to 10 texboxes and use it after that.
So as far as I know this code is only usable to load either every line to a seperate textbox, or to get the first line from a text file

My current code is:

Private Sub File1_Click()
Open File1.Path + "" + File1 For Input As #1
Line Input #1, a1
Line Input #1, b1
Line Input #1, c1
Line Input #1, d1
Line Input #1, e1

Text1.Text = a1
Text2.Text = b1
Text3.Text = c1
Text4.Text = d1
Text5.Text = e1
End Sub

Hope you can help

tnx in advance,

Maartuh03

How I Can Read A Specific Sector In A Cd-rom?
Hello everybody,
how I can read a specific track in a cd-rom through VB?
For example:
if I need to read the data contained in a specific zone of the cd-rom, can I pilot the head of the CD for read only that zone?
and if is possible, how?

thank you

Read A Specific Line
Hi i have a text file and i would like to read a specific lines in that file. any one with ideas on how i can do that?

Thanks

Read Specific Line
Hello,

I'm looking at writing a password generator that uses real words. In order to do this I've downloaded a relatively small dictionary text file, about 80K words (600kb), with a word-per-line.

Now, my problem is what is the best way to pick a word out of this file randomly, preferably with FSO?

Currently I count the number of lines in the file and use a random number generator to pick a number within the lines-of-file range. This is where I run into problems/issues. I can read each line into an array, and access the random element as required, but is this the best/most efficient way for such a large number of lines?

Thanks.

How To Read A Specific Line From Txt File?
I wan't to read lats say, line 5 how can I do it?


BTW:
How can I know the end (number) of array?
Or how can I check if array1(3) is ok? (If it's exist)

Read Line Until Specific Character
I'm trying to read in some lines from a text file but the only part I want is a number located at the beginning of the line, after the text is a space and then some text. How would I go about reading in only the number and stopping when I get to the space??

Read A Specific Character From An Array
I've this code:

Code:
Dim buffer As String
Dim bufferarray() As String
Open App.Path & "datasettingslicense.ini" For Input As #1
Line Input #1, buffer
Close #1
bufferarray() = Split(buffer, "-")
Now bufferarray(0) = "AGBS1"
I only need the "1" from this array. Does anyone knows how I can select just the "1" out of the array?

Thanx in advance.

How Do I Read The Value Of Each Row Of A Specific Column In A Database?
How do I read the value of each row of a specific column in a database?

For instance, I have several rows in a table. One of the columns is called 'name'.

How do I read all the values of 'name' and put them into a combo box?

Read File From Specific Point To The End??
I am attempting to read a file and write what I read to the end of another file. My problem is that I do not want to read the first part of the file I am reading. I need to find a "keyword" which tells me where to start reading and writing the information to the other file. Here is my code.... this code opens one file for reading and then writes the whole file to the end of the other file?

Do I need to do this line by line to accomplish what i need? The problem is the file i am reading is an extremely long html file.

dim fso as new FileSystemObject
Dim file as file
dim filetocopy as file
dim textstream as textstream
dim newTextstream as textstream

Set file = fso.GetFile(MyfilePath.html)
set filetocopy = fso.getfile(MyFileToCopy.html)
set textstream = file.OpenAsTextStream(ForAppending)
set newTextstream = file.OpenAstextStream(ForReading)
textstream.write newtextstream.readall
textstream.close
newtextstream.close
set file = nothing
set fso = nothing


Any suggestions

Thanks,

M

Read Only Status For A Specific People??
Hi,
I have been working on Excel VBA. I wanted to know whether there is any way that the excel spreadsheet status can be set to readonly for a specific group of users ??

How Do I Read Specific Memory Addresses??
I have a DLL that I am using with my VB program. It works great, but a few of the commands don't have return parameters, but instead a memory address.

For instance, when you want to request the Version you send the DLL "?" and it returns the version in rev%.

There are two commands that I need to use, the "^" and "&", but they do not have return parameters. They specify the following addresses:

"^" Address 0x002e

"&" Address 0x0030

How do I read these??

Any help greatly appreciated!

Long Is Faster Yet It's 4 Bytes And Integer Is 2 Bytes, And Other Data Type Questions
I read in the MSDN library that a long data type should be used whenever possible because it is the processors native data type and therfore more efficient. Why is this if it's 4 bytes and the integer is 2 bytes?

Also, it sayed you should only use decimal when absolutely neccessary when dealing with math so that the math co-proccessor is utilized less. What data type can I use that when divided by an indivisable value won't return a decimal value? I usually use the round() functiln.

Any help would be great thanks.

Need To Set Specific Cells In A Word Table To Read Only
Hello!

I am a VB developer that was suddenly thrust into the situation of having to make some changes to some word templates that are populated from a CRM package.

The request that was put before me was to set up a table in a word template where some cells will be auto populated and others need to be set to read only.

If this is possible, can someone please point me in the right direction?

Many Thanks :-)

How To Read Text File Of Specific Location?
Suppose I have the following text file:

Apple USA
Orange HK
Pear Japan
Grape Australia
Mango Thailand

I want to write a program, then user will input a query. For example, the user enter "Orange", then the program will read the text file, find the line which have "Orange" and then output "HK".

Is there anyway to read a line in text file only, which contain the query word. Because the file contains > 15000 lines, I don't want the program read the file line by line...... I want a faster method to get the line~~~

Thx

Read A Specific Line From Big Text File
How can I read specific line from big *.TXT file?
For example *.TXT file size is 200MB and I want read specific line from this file how can I do that ?

Read USB Drive And Copy Specific Files
Hi....
I am new to VB...I was wondering how to make an application which reads a USB drive when inserted and copy a single file or multiple files with a fix extension (e.g. *.doc) from the USB drive to local hard disk whenever the USB drive is inserted to the USB port...

any help and suggestion will be greatly appreciated....

thanks

Read From Specific Line In Text File
How can I read and write to a specific line in a textfile.

Say I want to write a string to say line 5 into info.txt and later I want read line 5 from info.txt

thanks Vidar

Make Specific Datagrid Columns Read Only
hi my question is that i want to make a datagrid which has first two columns readonly where as the other columns are used like text boxes for data entry

Read Specific Line Of Multiline Textbox?
I've only been working with VB for a very short time. I'm trying to read a specific line of a multiline text box. For example, I wish I could do something like this:

Dim Line4Data

Line4Data = txtBox.Text (line = 4)

Is there an easy solution to this? Everything I've read starts talking about SQL databases and blows my mind.

Thanks.

How To Read The Records In A File Into A Specific Control Array??
Hai guys,

I want to know whether there is any way of reading the contents of a file the records into a specific control array of text boxes??? If you dont get the problem then I am happy to explain it again.

The main problem is not the reading of the file I can do it properly but getting the particular record and then having it displayed on a specific text box which is in a control array by the click of a button. Please help


darkshade

How To Read Specific Excel Cell Value Into Integer Variable?
Hi,

How to read specific excel cell value into integer variable?

How Do I Read A SPECIFIC Line From A Text File ?? GURUS PLEASE HELP =)
A few easy questions for you gurus =)

1. How would I read a specific line from a textfile (for example line number 5)

2. How would i read a specific value in a text file? Lets say the file looks like an ini file:
thing1=value1
thing2=value2

How would i read/write from the specific value?? PLEASE HELP!!!!
Is it possible to search for a string in a file without loading it in a textbox? How would i then extract the value of thing2 for example then???

How Would I Read A Specific Line From A Text File As A String?
I would like to read configuration from a text file like config.txt
each line would look like: variable value (for example: version "0.9")

What code would i need to write if i only wanted to extract one variable and it's value from the config.txt?

How would i find the variable and read it's value ????


---------------------
~:{Decayed}:~
the.decayed@usa.net
http://www.q3seek.com

How Do I Fillmemory In Words (2 Bytes) And Dwords (4 Bytes)
I've made a program in DirectX7 that involves Direct Memory Addressing to the backbuffer surface to draw pixels super fast.
Heres the URL:

http://www.planet-source-code.com/vb...55262&lngWId=1

For the scanline program within it, I'm only limited to the Fillmemory API that only fills 1 byte memory blocks at a time (ByVal Fill As Byte), limiting me to only 256 colors.

Declare Sub FillMemory Lib "kernel32.dll" Alias "RtlFillMemory" (Destination As Any, ByVal Length As Long, ByVal Fill As Byte)

Now I want it to where I can fill memory in words (Integer = 2 Bytes) and dwords (Long = 4 Bytes). That way I have 65536 colors to choose from (2 bytes per pixel for 16 bit color) when I fill in words and 4294967296 colors to choose from (4 bytes per pixel for 32 bit color) when I fill in dwords. Replacing the Byte to Integer caused it to add 256 to every increment, showing its still limited as 1 byte.

Andre Lamothe (Author of many game programming books) has this assembly source to do what I want, but I don't really want the hassle of trying to mix assembly with VB and require everyone who uses my code to "make sure you have this add-in" and download MASM/TASM/NASM. Too much of a hassle if you ask me. Plus I don't really know much of assembly. Anyways, heres the source:

inline void Mem_Set_WORD(void *dest, USHORT data, int count)
{
// this function fills or sets unsigned 16-bit aligned memory
// count is number of words

//Write_Error("{");

_asm
{
mov edi, dest ; edi points to destination memory
mov ecx, count ; number of 16-bit words to move
mov ax, data ; 16-bit data
rep stosw ; move data
} // end asm

//Write_Error("}");

} // end Mem_Set_WORD

///////////////////////////////////////////////////////////

inline void Mem_Set_QUAD(void *dest, UINT data, int count)
{
// this function fills or sets unsigned 32-bit aligned memory
// count is number of quads

_asm
{
mov edi, dest ; edi points to destination memory
mov ecx, count ; number of 32-bit words to move
mov eax, data ; 32-bit data
rep stosd ; move data
} // end asm

} // end Mem_Set_QUAD
#End If
/////////////////////////////////////////////////////////

Is there any way I can do it WITHOUT the reliance of assembly? A mix of CopyMemory and FillMemory might help solve my problem in theory, just can't figure out how to do it. THANX.

-Jacob Roman

Follow-up To Tutorial: Files -> How To Read And Write Specific Records From/To A File
I understand all of the information in the FAQ that Xtab provided, but I also need the follow-up info containing this:

Quote:Although this is quite a long document, there are some areas we still haven't covered - the Seek and Loc Functions, deleting Records and searching for a Record containing a specific string, for example. Hopefully these will be covered in a follow-up FAQ, but at least for now you have the basics you need to be able to read and write to a Random Access file.


Greatly appreciated guys!

If ever you need me, just look to the sky and shout my name.
~The Cloudman~

How To Read Specific Excel Range Data Into Datagrid Using Two Date Values?
Hi,

Below is the code that reads a row of Excel data from an Excel File into Visual Basic.NET program datagrid, the code only reads one row of data. I want to add more functionality to the program, on the first column of each rows in the Excel file is date, by adding two datetimepicker in the VB.NET program one listed as start date and other end date. I would like datagrid to return all the data between this two dates, I have trying various scenarios but all unsuccessful. Hope someone can help me.


  Dim oExcel As Object
  Dim i As Integer

        Dim ds As New DataSet
        ds = DataSet1
        ds.Clear()
        DataGrid1.DataSource = Nothing

        oExcel = CreateObject("Excel.Application")

        Dim dr As DataRow
        oExcel.Workbooks.Open(Application.StartupPath & "MyExcel.xls", , False)


        With oExcel.WorkBooks("MyExcel.xls").Worksheets(cmbBox2.SelectedItem)

            dr = ds.Tables("Table1").NewRow

            dr.Item("Date") = .Cells(1, 1).Value
            dr.Item("Min Price") = .Cells(1, 2).Value
            dr.Item("Max Price") = .Cells(1, 3).Value
            dr.Item("Closed Price") = .Cells(1, 4).Value
            dr.Item("Change") = .Cells(1, 5).Value
            dr.Item("Volume") = .Cells(1, 6).Value
            dr.Item("Foreign Inv.") = .Cells(1, 7).Value
            dr.Item("Securities Trust Co.") = .Cells(1, 8).Value
            dr.Item("Dealers") = .Cells(1, 9).Value

            ds.Tables("table1").Rows.Add(dr)

        End With

        Me.DataGrid1.DataSource = ds.Tables("table1")
        Me.DataGrid1.Refresh()

        oExcel.WorkBooks("MyExcel.xls").Close(True)
        oExcel.Quit()
        oExcel = Nothing
        GC.Collect()



Edited by - roniwu on 11/13/2005 6:04:22 AM

Stupid Question (Read A Image Of Specific Color And Size In Video File?)
Hi...I m not sure if i should post this question in this forum...but here it is..

can a application be made that is in minimized mode and it detects a image of particular size and color (lets a rectangular black colored image of size 3 cm x 3 cm) in a video file being played on the desktop (full screen), and finds its X and Y position...thanx

Opening Excel, Selecting Book / Sheet - Read/write Data To/from Specific Cell Usinf WIN 3A
Please can someone inform me how to do the following using Win32 API functionds onlyl;

1) open excel
2) open a named bookbook and select specific sheet
3) read or write an entry into or out of a specific cell;

I have opend other programs before from a VB6 environment using shell execute statement, however in this problem I am not using VB6, rather a prorietary programming language that allows me to have access to WIN 32 API functions - so my problem has to be solved using these functions only.

Any one's help on this probelm is greatly appreciated.

Regards

adam

How Can I Read Only One Line Or Specific Line Of A Text File
How can i read only one line or specific line of a text file?

Copyright © 2005-08 www.BigResource.com, All rights reserved