Results 1 to 11 of 11

Get statement - Please help me understand how this works

Threaded View

mc84excel Get statement - Please help... 07-23-2015, 11:14 PM
mc84excel Re: Get statement - Please... 07-26-2015, 08:12 PM
Kyle123 Re: Get statement - Please... 07-27-2015, 07:04 AM
mc84excel Re: Get statement - Please... 07-27-2015, 08:11 PM
Kyle123 Re: Get statement - Please... 07-27-2015, 07:13 AM
mc84excel Re: Get statement - Please... 07-27-2015, 08:24 PM
Kyle123 Re: Get statement - Please... 07-28-2015, 03:41 AM
mc84excel Re: Get statement - Please... 07-28-2015, 06:22 PM
mc84excel Re: Get statement - Please... 07-28-2015, 08:45 PM
Kyle123 Re: Get statement - Please... 07-29-2015, 02:03 AM
mc84excel Re: Get statement - Please... 07-29-2015, 08:31 PM
  1. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Get statement - Please help me understand how this works

    As an example, opening a Jpeg, results in FFD8 FFE1 (which is correct - that's the magic number for a jpeg) for both methods
        Dim strFullName As String
        Dim intFNum As Integer
        Dim lngReadPos As Long, x As Long
        Dim BytGetHeader As Byte
    
        Dim avarBuffer As Variant
        Dim lngGetHeader2 As Long
    
        Dim hxValue As String
    
        'user prompted to pick file
        strFullName = fnstrFilePicker
        If Len(strFullName) > 0 Then
        Else
            MsgBox "You cancelled!"
            Exit Sub
        End If
    
        'method 1
        intFNum = FreeFile()
        Open strFullName For Binary Access Read Lock Write As intFNum
        lngReadPos = 1
        For x = 1 To 4
            Get #intFNum, x, BytGetHeader
            hxValue = hxValue & Hex(BytGetHeader)
        Next x
        Close #intFNum
    
        Debug.Print "Method 1: Header = " & hxValue
    
    
        'method 2
        hxValue = ""
        avarBuffer = fnavarUseFileOpenToCreateBufferArr(strFullName)
        For x = 0 To 3
            hxValue = hxValue & Hex(avarBuffer(x))
        Next x
        Debug.Print "Method 2: Header = " & hxValue
    Using a long in the same scenario results in -503326465, which has a hex value of FFFF FFFF E1FF D8FF
    Last edited by Kyle123; 07-27-2015 at 07:27 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. IF AND statement that works across a huge number of rows
    By kcphila in forum Excel Formulas & Functions
    Replies: 27
    Last Post: 07-10-2015, 01:09 PM
  2. [SOLVED] I want to understand what is behind A2 cell ? How this works ?
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2014, 01:36 PM
  3. IF statement works for some but not all?
    By refryguy in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-02-2014, 02:04 PM
  4. [SOLVED] If statement that only returns #value, however it works in another spreadsheet but has {}
    By michael_bemis2002 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-01-2012, 03:56 PM
  5. Replies: 1
    Last Post: 09-18-2007, 02:07 PM
  6. [SOLVED] SUMPRODUCT statement only works sometimes
    By Richard in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2006, 12:55 PM
  7. Select case statement - it will not work and i dont understand why! :o(
    By Thomas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2005, 01:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1