Solved

Picture / Object size

Posted on 2000-04-17
6
189 Views
Last Modified: 2013-11-26
I need to use the AppendChunk/GetChunk methods with an ADO recordset. The example in the MSDN uses the ActualSize property to get the object size but I want to put a picture from a file (via loadpicture). I basically need to find out the object size in order to break it into chucks for the append and get chunk methods.

By object size - I DON'T mean width or height, I mean the byte size in total.

Thanks,

StuJ
0
Comment
Question by:scj1
  • 3
  • 2
6 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 2722692
Check the filesize, this will give you the answer

    Dim lngFileSize As Long
    Open "Picture.bmp" For Binary Access Read As #1
    lngFileSize = LOF(1)
    Close #1
    MsgBox lngFileSize
0
 
LVL 1

Author Comment

by:scj1
ID: 2722742
Ok, I have though of this but that will only help if the picture is a bitmap file. Is there a way of getting the size from the object reference?

Thanks.
0
 
LVL 1

Expert Comment

by:Ask_ED
ID: 2722853
Hi,

Tim's got the right idea and it isn't limited to only bitmaps any file type (GIF/TIF/JPG..etc) can be sized that way... but I'd recommend using the FileLen function instead.

msgbox FileLen(pathname)

If you use the FileLen function, you do not have to explicitly "open" then file, thereby eliminating that overhead.

Hope this helps
ED
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:scj1
ID: 2723132
The point here though, I realise that the file length, however you get it, will return the filesize. However, I wasn't planning on storing the file but rather the file contents. Thus, if a jpeg or compressed gif/bmp/etc. is used, the ipicturedisp object will generally be the same despite differing file sizes (lossy compressed files excepted from this rule).
0
 
LVL 1

Accepted Solution

by:
Ask_ED earned 100 total points
ID: 2723366
Hi Again,

Isn't your goal to find the ammount of data you need to append to the database ???

Knowning the size in memory of the 'object' isn't going to help you append to the database.

Unless you have a high-end graphics control or class you are still going to have to save the image back to the disk before appending it to the database, so the important value is the file size and the object size is a "nice to know", but not required bit of data.


Am I missing something here ?

Bye for Now
ED
0
 
LVL 1

Author Comment

by:scj1
ID: 2747891
I've actually solved the problem now and as you rightly said, I did need to save the object to disk before I could right it to the database. This does, however, seem a bit of a wasteful way of doing things - wouldn't it be better if I could just put the object in memory to the database rather than through a broken up file. After all, what is the image datatype for otherwise?

Cheers,

Stuart
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
change vba from autofit to 13.5 width? 4 28
message box in access 4 41
Exit a vb6 apps when a calling it apps closes 15 43
Protecting vb6 & .Net code Obfuscation 18 96
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now