|
Can you provide an example of the date value that is coming from the file?
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
The type conversion is going to depend on what the DWORD value actually represents. Is it a number of seconds since a given base time?
If so, do a DateAdd to add the DWORD value to the base time.
Hope that helps...
Tim
|
|
|
|
|
Thank you both for helping.
The DWORD in the file (big-endian) is 06 00 42 11 (four bytes). I swap the bytes first and place the result in a UInt32 variable (hDWORD).
msg &= Hex(SwapDWORD(br.ReadUInt32)) results in the decimal "06004211".
Yet I don't find a way to convert that value neither to a time-string (e.g. "06:00:42:11") for the list box nor to a DateTime data type. One more "horror" is the thought that - after reading and correcting the time stamp - I will have to write it back to the file...
What do you think?
|
|
|
|
|
Well, I'm half in a daze today and my brain is NOT working at 100%, so all I have is a cheesy solution like this:
'Read from file
Dim DwordValue As String = "06004211" 'IE: Hex(SwapDWORD(br.ReadUInt32))
'Format value.
Dim FileTime As String = Strings.Left(DwordValue, 2) & ":" & Mid(DwordValue, 2, 2) & ":" & Mid(DwordValue, 4, 2) & ":" & Strings.Right(DwordValue, 2)
'To resave current or new value:
FileTime = Strings.Replace(FileTime, ":", "")
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
|
With enough caffeine, I'll eventually come around.
With the previous example, you could use a set length stringbuilder if you're processing a large amount of data.
If the time value is always going to come in at the same length, you could probably also use a regeex to format the value.
Just throwing out some ideas.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
Wow - you must really have had some caffeine already
I started reading a bit about stringbuilder and regEx, and I think especially regular expressions could be a powerful way to solve it! As written in my last (edited) response to Tim, it's a movie time-code I'm dealing with. The address in the header is always the same, it's always 4 Bytes, and it should always be formatted as "00:00:42:11" (e.g.)
As a consequence I would need to determine a regEX which starts from the RIGHT side of the string - as in the case of 0 hours and 0 minutes the string would be much shorter. Would that work? (I'm only at chapter 1 with my reading...)
Hoping your ideas flow on like that
|
|
|
|
|
Since it sounds like a regex will work for you and that you'll be processing a large amount of records, see if you can 'compile' the regex (using the RegexOptions.Compiled or Regex.CompileToAssembly option). This will ensure your regex is compiled directly into MSIL code. There's a slight trade off in that it will take a little longer for the regex to load and how it is destroyed; but once loaded will operate much faster. Really not to bad to implement at all.
Check out this ebook and review the section on regular expression (starts at end of page 65) vs a compiled one (whether inline or to an external assembly).
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
Thank you so much... really !!! I downloaded the book and will check that out asap. Still I have to admit that the compiling- and assembly-stuff is a bit too much for a newbie on VB Express at the moment
By now (started studying already) I haven't found anything about a pattern which I can apply from right to left of the string. So in case your next coffee brings up one more idea you can bet on highest rating from me
Just in case you're into graphics, too (still it would surely have to be a separate thread): I'm searching for a way to shift a stripe of 12 pixels from the right edge of a bitmap to it's left edge - just as if I would cut it from the right hand side of a photo print and glue it to the left side... some challenges I'm facing, no?
It's late over here so I might go to soon.
Thanks a lot, man!
Regards from Munich
Michael
|
|
|
|
|
Michael Schäuble wrote:
It's late over here so I might go to Sleepy soon.
Actually, I'm gonna bonk out as well. I'll look into your questions tomorrow sometime.
As far as reversing the regex, not sure I'm following you there. You can always just reverse the string if needed:
strings.StrReverse("abcdefg")
results in: "gfedcba"
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
Had a quick look back, and - as promised - your next idea deserves top rating again! (I'm missing a smiley with a light bulb here!)
What I meant: The leading zeros get cut when reading the numbers string from the file. Depending on the relevant time code I might have to read "10:20:15:24" in one file and "5:11" (i.e. 5 seconds 11 frames) in another.
But - BINGO - reversing the header-string (which has no colons), then re-formatting it with the colons and reversing it back would be the deal!
Great, much appreciation (!)
and have a nice evening
Michael
p.s.: I guess I'll have to ask you for your coffee brand next time
|
|
|
|
|
when i tried Dim fs As FileStream = New FileStream((mImageFilePath.ToString(), FileMode.Open) i am getting error message like the image is already using by another process what to do
|
|
|
|
|
It depends on what you are trying to do with the file. You may have to make a temporary copy of the image file and run your processing on that copy instead of the original.
|
|
|
|
|
hai friends
how to Insert a picture in Excel file in a particular Cell
say D25
plz help me
thanks in advance
bye
vijay kumar d
|
|
|
|
|
vijaylumar wrote: how to Insert a picture in Excel file in a particular Cell
say D25
ActiveWorkBook.Sheets("Sheet1").Select
ActiveWorkBook.Sheets("Sheet1").Range("D25").Select
ActiveWorkBook.Sheets("Sheet1").Pictures.Insert([Full path to image here])
HTH
|
|
|
|
|
hello sir i want to create vb project Setup through installshield
and crystal report automatically install through setup
saurabh bhardwaj
|
|
|
|
|
for automatically install crystal report you need to add the crystal report related files by adding merge modlue in ur ssetup.
Thanx hem
|
|
|
|
|
I have created an application which reqiures some administrative privilages.
I am getting problem when program is run by a guest user.
I want to write some code to check if user is administrator or not.
How can i do this...
Help Me...
Gagan
|
|
|
|
|
Hello Gagan use the following code to check if the user is administrator or not...
System.Security.Principal.WindowsIdentity wi = System.Security.Principal.WindowsIdentity.GetCurrent(); System.Security.Principal.WindowsPrincipal wp = new System.Security.Principal.WindowsPrincipal(wi);
if (wp.IsInRole("Administrators"))
MessageBox.Show(wp.Identity.Name + " is an Administrator!");
|
|
|
|
|
Thank You for your help HemJoshi
|
|
|
|
|
Do:
If My.User.IsInRole(ApplicationServices.BuiltInRole.Administrator) Then
' Do whatever here.
End If
My.User.IsInRole Method[^]
|
|
|
|
|
Thank you for your help The JZ
|
|
|
|
|
But I want to check this before form loading event.
if user is administrator then
'code here
else
application.exit
endif
Help me...
Gagan
|
|
|
|
|
Form load or Sub New?
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
Is there anything in vb.net similar to OnBeforeKeyPress.
Thanks & Regards
Mishra
|
|
|
|