|
I'm using VB 2005, and you're not. That's why the problems...
"<<" is a bit-wise shift operator that finally appeared (many years too late!) in 2005. To get the same effect using math, you need to multiply the value by 2^(number of bits to shift left). Sooooo, the same operation can be done like this:
Dim dt As New DateTime(((CType(ft.dwHighDateTime, Long)) * (2 ^ 32) Or CType(ft.dwLowDateTime, UInt32))
Because of the math, it's quite a bit slower, but it does the same thing.
As for the other problem, IIRC, since the values involved are small, you can get away with changing the data types in the SYSTEMTIME structure to Int16 and it'll still work.
<StructLayout(LayoutKind.Sequential)> _
Private Structure SYSTEMTIME
Public wYear As Int16
Public wMonth As Int16
Public wDayOfWeek As Int16
Public wDay As Int16
Public wHour As Int16
Public wMinute As Int16
Public wSecond As Int16
Public wMillisecond As Int16
End Structure
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Then I still have the problem that I cannot convert the dwLowDateTime to Uint32. As in the original problem. The thing I don't get is that this convertion works fine for C# and vb.net
Think, try, think, think, try, think, think, think, try, ASK, think, try, advance on step and start over...
|
|
|
|
|
OK. You can change that UInt32 to Long an it'll work.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
Tried this, assuming that is what you meant ...
Dim dt As DateTime = New DateTime(((CType(ft.dwHighDateTime, Long)) << 32) Or CType(ft.dwLowDateTime, Long))
But then I get the exception message:
"Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
Parameter name: ticks"
Think, try, think, think, try, think, think, think, try, ASK, think, try, advance on step and start over...
|
|
|
|
|
Hmmmm...I never got that message in testing. What's the value of the High and Low in ft when it fails? Even better, also, what's the values in st before the call to SystemTimeToFileTime?
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 18:50 Thursday 13th April, 2006
|
|
|
|
|
Here are the value for st :
wDay: 31
wDayOfWeek: 5
wHour: 23
wMilliseconds: 0
wMinute: 0
wMonth: 12
wSecond: 0
wYear: 3604
whith wich values are you testing?
Think, try, think, think, try, think, think, think, try, ASK, think, try, advance on step and start over...
|
|
|
|
|
OK. This should do it. The problem is that the bitwise math isn't working as it should because one of the value types in the FILETIME structure isn't what it appeared to be.
Dim dt As New DateTime((ft.dwHighDateTime * (2 ^ 32)) + ft.dwLowDateTime)
I'd beat the snot out of this code before putting it into production.
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 19:42 Thursday 13th April, 2006
|
|
|
|
|
Hi Dave,
Fixed it in a more convential way ... :
Private Shared Function SystemTimeToDateTime(ByRef st As SYSTEMTIME) As DateTime
Dim dt As DateTime
Dim dtFormat As String
Dim en As New CultureInfo("en-GB")
dtFormat = "dd/MM/yyyy HH:mm"
With st
dt = DateTime.ParseExact( _
Format$(.wDay, "00") & "/" & _
Format$(.wMonth, "00") & "/" & _
Format$(.wYear - 1600) & " " & _
Format$(.wHour, "00") & ":" & _
Format$(.wMinute, "00"), dtFormat, en.DateTimeFormat) ' & ":" & _
' Format$(.wSecond, "00"), dtFormat, en.DateTimeFormat)
End With
Return dt
End Function
Gues it is a bit less efficient, not sure how much though.
Your remark about the code and the snot was that just about this problem or also about the rest of the code. If so could you give me some pointers, guess it is never too late to learn. )
Cheers
David
Think, try, think, think, try, think, think, think, try, ASK, think, try, advance on step and start over...
|
|
|
|
|
Hi How can I open and read msg file information such as from, to, subject, location, when for appointment and body programmatically?
i tried to use redemption but I'm missing some information such as location and when for appointment.
how many type of attachments in email?
When I try to read email attachment, I would like to know what type of attachments are?
|
|
|
|
|
You'll have top open this file in the application that wrote it. I take it your using Outlook? Outlook has a COM-based object model that can get this information for you. This[^] article on MSDN should get you started.
pnpfriend wrote: i tried to use redemption
Redemption?? Are you praying for this to work? Are you in need of forgiveness? We can't really handle issues of the faith here at CP.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Yes I'm trying to use redemption[^]
to get the msg file information such as To, From, Subject, Body and if the msg file is appointment file, I'm trying to get Location and Start time of that appointment.
But I dont know how to get the appointment date, time and location.
|
|
|
|
|
pnpfriend wrote: to get the msg file information such as To, From, Subject, Body and if the msg file is appointment file
For that, you're going to have to get ahold of the people who wrote Redemption and ask them. From what I can see, RDO doesn't support Appointment objects. SafeAppointmentItem looks like it supports what you want, but the documentation isn't exactly complete.
As far as attachments go, Outlook doesn't care about what the file types are. So, you'll have to get the filename of each attachment, specifically the .extension, and P/Inokve Shell functions to lookup what that extension is registered to.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello
I am new to .net.
I need to know the following information.
1.How to declare global variables.
2.where to declare ( in VB6 used to declare those in Modules what about 2005?)
3.How to make the application Run the Sub Main() function?( I saw in VS2005 My Project Tool and it shows only forms which are in the projects and it didnt show the module which i have added which contains a main function and i have tried to add a class and tried the same and still no luck.
5.How to end the application Frmmdiform.END?
Thanks for the reply in advance
Regards
Help in need is the help indeed
|
|
|
|
|
percyvimal wrote: 1.How to declare global variables.
Global variables don't exist in the .NET Framework. They're also bad practice. You can simulate something close by declaring your variables as Shared in another class:
Public Class HelpersLibrary
Public Shared myGlobalVariable As Integer
End Class
percyvimal wrote: 2.where to declare ( in VB6 used to declare those in Modules what about 2005?)
Modules are an outdated concept. They're only there for backwards compatibility with VB6.
percyvimal wrote: 3.How to make the application Run the Sub Main() function
You actually have to turn off the "Enable Application Framework" option in My Project before Sub Main will show up in the list. After that, all you have to do is supply a Sub Main in either a Module or a Class. For a Module, add a new one to your project, then put something like the following code in it:
Module MainStartupCode
Public Sub Main()
' Your startup code begins here
' To launch a form and start your Windows GUI:
Application.Run(New mainForm)
End Sub
End Module
Or, to support command line arguments:
Module MainStartupCode
Public Sub Main(ByVal cmdArgs() As String)
' Your startup code begins here
' To launch a form and start your Windows GUI:
Application.Run(New mainForm)
End Sub
End Module
Now, you don't have to have a Module to supply a Sub Main . You can do it with a Shared member Sub of a class:
Public Class Form1
<STAThread()> _
Public Shared Sub Main()
' Same as above examples...
End Sub
' the rest of your form code goes here...
End Class
Don't forget to go back into MyProject and select Sub Main < from the Startup object dropdown.
percyvimal wrote:
What happened to 4?
percyvimal wrote: 5.How to end the application Frmmdiform.END
Me.Close()
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thank you very much Mr Dave
That is great explanation.I am still in the world of VB6 and so need to crawl to get into the world of .NET and people like you i hope will take me in the right direction.
Sorry for the Numbering Error.
"You actually have to turn off the "Enable Application Framework" option in My Project "
This helped me a great deal for i was scratching my head why submain was not listing in the dropdown.
Regarding No3:
Now, you don't have to have a Module to supply a Sub Main. You can do it with a Shared member Sub of a class:<br />
<br />
Public Class Form1 <STAThread()> _ Public Shared Sub Main() ' Same as above examples... End Sub ' the rest of your form code goes here...End Class<br />
<br />
According to your example Form1 --should be the start up form?Could you able to explain how it works.I assume my Sub Main will be triggered first where whatever i wrote as code will be executed and then formLoad event?
Me.Close()= ME.END in VB6 ie does it free up the application from memory?
You have suggested that using global variable is not such a good practice and i have read in some article also that it is not a OOPS concept to have global variables.
So what is the best and alternative way. Do i need to create a class with get and set parameter in a class to store that values? I would like you hear from you what is the best method to be followed to keep global variables?
Thanks and Regards
Help in need is the help indeed
|
|
|
|
|
percyvimal wrote: According to your example Form1 --should be the start up form?
A Shared sub can be called without an instance of the class that contains it. Once the Sub Main is created inside ANY public class in your app, you can set it to the be Startup object in the MyProject properties.
Me.Close will close the form that it shows in. If this is the only form in your app, then it will send the WM_CLOSE message to itself. Or, you could replace it with Application.Exit and it will close your entire application, no matter what form it's called in.
And, yes, all the (managed) memory your app uses will be freed.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Another method. Create a class like below
Public Class clsGlobal
Public Shared Caterory As String 'Global variable for current programm-mode Audio or Video
Public Const const_SqlExtAudio As String = "SELECT Media_Extensions.MediaExtension, =" + _
"Category.Category FROM Category INNER JOIN Media_Extensions ON Category.ID = " + _
"Media_Extensions.bez_Catgory WHERE (((Category.Category)='Audio'));"
End Class
to access the variable e.g. Caterory :
clsGlobal.Caterory = "Test"
|
|
|
|
|
Thank you very much mr Dave and Cosma, with your help i am getting into .net now and really appreciate your nice explanations and very useful information.
with regards
Help in need is the help indeed
|
|
|
|
|
i send a vairable to another application but some time the variable damage and add some thing diffrent ... i dont know why ...
for example :
dim s as string ="4294:DN"
windows.minimaiz
send.sendwait("s")/ print in active window
windows.maximize
the problem the first time print the s as 4294:DN on the another window but aftet repeat the action of print the variable will print some thing deffirent like 44294:::DN
why the variable change ??????????
kilany
|
|
|
|
|
Mr kilany wrote: i send a vairable to another application
How are you doing this? There's only about a dozen different ways...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
i send variable by this fuction
dim ss as string = textbox1.text // here imagen i put "2415666:"
/// here code whcih minimaze the form of vb.net
System.Windows.Forms.SendKeys.SendWait("ss")// here the code which different and change . and after many click of button which make this action the string will print as "245566654" or some thing wrong .. the question why the variable printed like this ....
///here code whcih minimaze the form of vb.net
kilany
|
|
|
|
|
Copy and paste the ACTUAL code, don't retype it here.
What your saying is happening is impossible from the code that you've posted.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Try
Dim cone As New Conection
Dim ii As Integer = ds.Tables(0).Rows(ComboBox1.SelectedIndex).Item(0)
Dim sh As String = cone.get_Special_data("select Switch_Access_Code from Swiches where Swich_ID=" & ii & "")
b2 = ""
b2 = sh
Me.WindowState = FormWindowState.Minimized
System.Windows.Forms.SendKeys.SendWait(b2)//b2="2494:" come from //database on sql server
Me.WindowState = FormWindowState.Normal
b2 = ""
Catch ex As Exception
MsgBox("الرجاء اختيار القسم")
End Try
End Sub
some times when i click on this button will type on active window 4294: but aslo some time type 44294: and some time 4294:: and some time 4294: and some time 4449942: althought the data which comes from data base is just 4294:
why the variable b2 some time print wrong data not as want ???????
kilany
|
|
|
|
|
Don't make me repeat myself....
The problem is not the variable, but the method in which your code is TYPING it into the other application. I just got done telling you that you've chosen, possibly, the worst method to pass data to another application. SendKeys is NOT guaranteed to put the data into that TextBox exactly as sent. This is because SendKeys cannot control how the keystrokes you're sending are processed by the other app.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dear.
sorry ... but can you give me a best method which pass data to another application ...
really i need to use it ...and the way to use it ?
kilany
|
|
|
|
|