As for searching multiple pages, I seem to recall that what I did was to simply move the ScrollBar. The scroll event fired and did the rest.
Problem here is that i only read 1K of the file at a time.. (what you see on the form is whats loaded into the byte array) in order to try and keep away from the 'Out of memory error' you picked up previously. Although that was mostly because of the memory used by the 1024 textbox's
So i will need to read the next block (and maybe include the last 100 bytes of the previous block) and search again..
Originally Posted by WizBang
For pasting past the end of the page, the first thing that comes to mind is to require the data be written to file, then it will already be there when scrolling. Binary mode doesn't set the EOF marker, so that's no problem. Optionally I suppose you could use a temp file. Other things will likely come to mind after I click submit
Or after you logout..
The thing here again is the 1K block of loaded data.. File additions will be in steps of 1K (Or 512 bytes if used in narrow mode) Also setting a new EOF earlier in the file (Cutting a file shorter) cannot work with out using a new temp file... But i'm not to sure if i need to go in that direction ??
Originally Posted by WizBang
Checking for an image file header **shouldn't** be too difficult. I think I ran into a code snippet on PSC for detecting a number of header types, though it's probably gonna need some tweaks too.
On my way there now...
Thanks for your Valuable input Wizbang.. Your enthusiasm (<--- I know, my spelling is bad, But CG doen not have a 'F7' function,, Spellchecker ) with this little progect of mine has made it worth my while to write, when compleate I'm contemplating posting it on PSC.. So it can help 100's of others.. (Ahh CG users will have first option though)
Problem here is that i only read 1K of the file at a time.. (what you see on the form is whats loaded into the byte array)...
So i will need to read the next block (and maybe include the last 100 bytes of the previous block) and search again..
I understand that, but mine also loaded in small blocks (I think it was 2k) to avoid overloading the textbox. Moving the position shouldn't be a problem. As it was a quick thing, I didn't bother to overlap the read, but you're correct on that. One thought is to load more than you display. Just don't load it all into the box at once.
Loading more than 1k would solve the pasting past the end of the box issue too
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
I understand that, but mine also loaded in small blocks (I think it was 2k) to avoid overloading the textbox. Moving the position shouldn't be a problem. As it was a quick thing, I didn't bother to overlap the read, but you're correct on that. One thought is to load more than you display. Just don't load it all into the box at once.
Loading more than 1k would solve the pasting past the end of the box issue too
Thanks.. I think that after spending so much time if front of the same code, i must have developed 'Coders Block' . after a bit of CG, A quick trip to the store for something to drink and smokes. I think i'm ready to continue..
Also i found this code snip on PSC, I think i may just be able to use this to pick out even the embeded files.. (Bmp or Gif embeded in a binary file, etc.)
One thing I meant to ask you before is why you use the Hex_2_Byte function to get the value of a hex string? Wouldn't it work to just use Val("&H" & HexString)?
I built the hex_2_byte function to clean up the hex, and return a byte variable..
if hexstring happend to be "100" using Val("&H" & HexString) would cause a overflow error with the byte array..
Likewize with Hex_2_long, Val("&H" & "0000FFFF") returns -1 and not 65535.
For pasting past the end of the page, the first thing that comes to mind is to require the data be written to file, then it will already be there when scrolling. Fixed Up
Checking for an image file header **shouldn't** be too difficult. I think I ran into a code snippet on PSC for detecting a number of header types, though it's probably gonna need some tweaks too.Implemented
Okay i know it gets a bit fustrating when updates apears so quickly one after the other.. but this is not just surface updates, Its some what of majour surgery.. The search works 99% (Even added a search for next). Popup Paste now can paste text of any size (tested with a 18K clipboard). Ctrl + C calls the popup paste.. Auto File writing, added to the options menu..
Also a few small issues repaired ...
Gremmy.
---- New version in later post....
Last edited by GremlinSA; January 22nd, 2006 at 02:59 PM.
I built the hex_2_byte function to clean up the hex, and return a byte variable..
if hexstring happend to be "100" using Val("&H" & HexString) would cause a overflow error with the byte array..
Likewize with Hex_2_long, Val("&H" & "0000FFFF") returns -1 and not 65535.
Well, I haven't looked over your code enough to see when/if that can happen, but there is an easy fix for that too
To limit a value to 8 bits, just use:
Val("&H" & HexString) And 255
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
Well, I haven't looked over your code enough to see when/if that can happen, but there is an easy fix for that too
To limit a value to 8 bits, just use:
Val("&H" & HexString) And 255
I just found that Clng ("&HFFFF") gives 65535 and not -1 ..
Modifing the looooooonnnnnngggg Hex to val codes to use this now ...
Gremmy...
------- EDIT -----
The hacks at M$... CCur does the same as Clng...
Code:
Quote = VB Books Online....
Conver. Converts an expression to
function
CByte Byte
CCur Currency
CDate Date
CDbl Double
CInt Integer
CLng Long
CSng Single
CStr String
CVar Variant
And ...
Currency (scaled integer) 8 bytes -922,337,203,685,477.5808 to 922,337,203,685,477.5807
But a Simple CCur ("&H1FFFFFFFF") Returns a OverFlow error ...
I wont be surprised if CCur is the Clng code ....
Last edited by GremlinSA; January 16th, 2006 at 04:14 PM.
1) Using the logical edit doesn't enable the "Functions" menu. FixedThis actully was not done in any of the popups..
2) Typing non-numeric characters into the logical edit window textbox raises an error. Fixed
Thanks for those .. I missed them.. Testing your own code you sometimes forget to check these things..
Also .. If the file open Failed (Running exe or locked File) the editor kicked in with a blank form.. Fixed this problem too...
Made a few other minour changes and fixes. Corrected the Application Caption, and added the open file name to it. Made default buttons on the Entry forms..
Sorted out the Tabindex order into a logical Tab order..
It runs pretty nicely now... (although i still would like to speed up some of the editing code... )
AND.... This zip is a bit smaller because the code is quite a bit shorter using Clng, Cbyte and Cint .. Thanks for pointing me to that... I never knew that Val (And the others) translate Hex vals so easily... ( Well I never tried with "&H" prefix) ...
Enjoy...
Gremmy..
PS.. next on my list of incomplete Projects is the IPLink App i posted Here ... But i will start a new thread for that one... when this one is done...
a Little Nip and tuck on some code here and there...
----- NEW File on later post... -------
Last edited by GremlinSA; January 17th, 2006 at 05:58 PM.
Reason: Newer File on later post...
Hate to burst your bubble, but the first thing I tried was "Find in File...". I typed a zero into the box, and got an error in the Hex_2_Byte function. I changed CByte to Val and no more error.
Can you use the length of the input to determine the byte length? Then only one function would work for all.
Another way might be to have a parameter for the length. The function below works either way. If you leave out the length param, it will use the length of the input hex value:
Code:
Public Function Hex_2_Number(ByVal Hexadecimal As String, Optional ByVal Length As Long) As Long
Dim Tmp_Hex As String
If Length = 0 Then Length = Len(Hexadecimal)
Tmp_Hex = Right$(String$(Length, 48) & Hexadecimal, Length) ' split 2 digits for Byte...
Hex_2_Number = Val("&H" & Tmp_Hex)
End Function
I didn't look at why more than 32 bits would need to be supported, but if it does you can return a Currency type. I've also used a string to prevent overflow when the number might get huge. It just depends on how you end up using it.
Last edited by WizBang; January 17th, 2006 at 05:47 AM.
Reason: typo
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
Hate to burst your bubble, but the first thing I tried was "Find in File...". I typed a zero into the box, and got an error in the Hex_2_Byte function. I changed CByte to Val and no more error.
Where ???? ... I tried to duplicate this error... But to no avail.. works 100 % here...Could you maybe post a bit more info on this please..
Originally Posted by WizBang
Code:
Public Function Hex_2_Number(ByVal Hexadecimal As String, Optional ByVal Length As Long) As Long
Dim Tmp_Hex As String
If Length = 0 Then Length = Len(Hexadecimal)
Tmp_Hex = Right$(String$(Length, 48) & Hexadecimal, Length) ' split 2 digits for Byte...
Hex_2_Number = Val("&H" & Tmp_Hex)
End Function
the problem with Val is if you pass two bytes it treats it as an Integer, even if you preceed it with two 0 bytes.. try this in the immediate window..
Code:
Print Val("&H0000FFFF") ' Returns '-1' - In long its supposed to be 65535
Print Val("&H00010000") ' Returns '65536' - correct..
But what i did find is that a Search for &H 00 00, does not happen..???-- Currently looking into this...
Thanks
Gremmy....
Last edited by GremlinSA; January 17th, 2006 at 02:02 PM.
OK. Now I get what you have been saying. There is an easy fix for that too, shown below.
Code:
Public Function Hex_2_Number(ByVal Hexadecimal As String, Optional ByVal Length As Long) As Long
Dim Tmp_Hex As String
If Length = 0 Then Length = Len(Hexadecimal)
Tmp_Hex = Right$(String$(Length, 48) & Hexadecimal, Length) ' split 2 digits for Byte...
Hex_2_Number = Val("&H" & Tmp_Hex & Chr$(38))
End Function
As for the error, I've attached a screenshot:
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
Okay.. I do Belive you.. But strangly enough, It did not cause and error on my system.. ( i even downloaded the atachement and tried that)..
So .. I step traced the Bugger, Found the problem, and fixed it....
Also.... I found code to Set the EOF. You can now make files shorter. (Dont just play with this... IT IS DESTRUCTIVE.. Any thing after the New EOF, is now Lost... Forever... )
+ other minour fixup's and re-aranging.
Gremmy..
----- Newer Version in later post.....
Last edited by GremlinSA; January 22nd, 2006 at 03:01 PM.
I actually hadn't gotten to look at the last one I downloaded, but I just took a quick glance at this one. I did see a few things, but as usual, my coding style is so different from most others that I find it difficult to follow. I'm not at this moment sure what the usage is for all those binary/hex/decade functions. Maybe you can point some out for us/me? The ones I looked into seem to rely on each other in a maze of confusion...or I'm just lost...lol
Anyway, I saw this in your BinaryToHex function:
Code:
Do
sPart = Mid(sBinVal, iPos, 4)
sHex = sHex & BinToHex(sPart)
iPos = iPos + 4
If iPos > ilg Then Exit Do
Loop
It doesn't take full advantage of the Do...Loop structure. Why not do it like this?:
This eliminates the extra If...Then, which I'm sure must be faster. You can alternatively use Do While. The returned type of the function is also undefined, which means a Variant. That's gonna slow things down too, but I know it's just an oversight.
Also found two bugs:
1) If you click File >> Open... but cancel, the file you are looking at is no longer "enabled", and you have to open it again.
2) The scrollbar (nice feature I've been waiting for) always seems to scroll past the end of the file until the valid part goes off the screen. Is that on purpose for some reason?
I'll try to take a more in-depth look a bit later...keep up the good work!
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.