|
Checked it out. Doesn't seem to do the trick. It will return in days but I need to count down.
IE(10/22/2005 to 11/22/2006 is 1 year 1 month 0 weeks and 0 days)
|
|
|
|
|
You can easily do this with just DateDiff and DateAdd.
Just create a function that first calculates the difference in years using DateDiff. Subtract that value from the original End date using DateAdd. Then calculate the difference left in months from the new temp End Date. Subtract that value from the new temp date to recalculate a new value for the temp end date, which should now only be different by days. Take the days left and split them into weeks and residual days left.
|
|
|
|
|
im_hoser...
The message displayed at the end of the below code displays the correct 2 years, 8 months, 2 weeks and 3 days. The only protection missing is checking, before this code is executed, whether or not the from date is after the to date; but, I'm sure you have that covered already.
This looks like a very useful routine. Think I'll put it into a Double Text library so I have it whenever I need it.
George
Dim Years As Integer
Dim Months As Integer
Dim Weeks As Integer
Dim Days As Integer
'** Create a couple of dates to play with
Dim TempDate As Date ' Working date
Dim FDate As Date = Now ' The first, or from date
Dim LDate As Date = DateAdd(DateInterval.Year, 2, FDate)
LDate = DateAdd(DateInterval.Month, 8, LDate)
LDate = DateAdd(DateInterval.Day, 17, LDate) ' The last, or to date
'** Determine the number of years in the interval
Years = DateDiff(DateInterval.Month, FDate, LDate)
Years = (Years - (Years Mod 12)) / 12
'** Advance the first date up by the number of years
FDate = DateAdd(DateInterval.Year, Years, FDate)
'** Determine the number of whole months
'** Calculate the raw number of months
Months = DateDiff(DateInterval.Month, FDate, LDate)
'** Set up a temporary date that is the first date advanced by
'** the number of raw months
TempDate = DateAdd(DateInterval.Month, Months, FDate)
'** If the raw number of months is too many, back off by 1 month
If DateDiff(DateInterval.Day, TempDate, LDate) < 0 Then
Months -= 1
End If
'** Advance the first date by the number of months
FDate = DateAdd(DateInterval.Month, Months, FDate)
'** Determine the number of weeks and days
Weeks = DateDiff(DateInterval.Day, FDate, LDate)
Days = Weeks Mod 7
Weeks = (Weeks - Days) / 7
MsgBox(Years & ControlChars.CrLf & _
Months & ControlChars.CrLf & _
Weeks & ControlChars.CrLf & _
Days & ControlChars.CrLf)
|
|
|
|
|
im_hoser...
As part of preparing this code for saving in a Double Text library, I reworked it a bit. It's should now be more accurate. If you would prefer the revised code, please download this text file from my web site.
http://www.2goodsoftware.com/snippets/intervalcalc.txt
|
|
|
|
|
Thanks George. Very nice code.
|
|
|
|
|
Does anyone know a good way to install an application on a remote computer. Our company has 4 locations and right now I am having to remote desktop in to each to load updates. I was wondering if there was a installation utility or code for one that allows you to install an app on remote computers from a central location.
Jim
Jim Wilcox
|
|
|
|
|
|
hellow to all..
i am writeing a code that works on database in sqlserver ..
i wrote the following code
Dim sSQL As String
sSQL = "Select * From Cities"
Try
conSQL.Open()
Dim MyDataReader As SqlClient.SqlDataReader
Dim MySqlCommand As SqlClient.SqlCommand
Dim MyDataSet As DataSet = New DataSet
Dim MySqlDataAdapter As SqlClient.SqlDataAdapter
MySqlDataAdapter.SelectCommand = New SqlClient.SqlCommand(sSQL,conSQL)
MySqlDataAdapter.Fill(MyDataSet)
MySqlCommand.Connection = (conSQL)
MySqlCommand.CommandText = sSQL
MyDataReader = MySqlCommand.ExecuteReader
Do While MyDataReader.Read
cmbCity.Items.Add(MyDataReader(0))
Loop
MyDataReader.Close()
conSQL.Close()
conSQL.Dispose()
i get the following error
"Object refrence not set to an instance of an object"
thank's for the help ..
|
|
|
|
|
The problem is with "MySqlCommand".
You need to have it reference an object before using it.
|
|
|
|
|
u mean to make it like this ?
Dim MySqlCommand As SqlClient.SqlCommand = New SqlClient.SqlCommand
|
|
|
|
|
Right. But from the looks of things, your code needs to be cleaned up a bit more.
First of all, you're trying to execute the same SQL command twice. Was this the intent? (I don't think so.)
You're reading it once here...
MySqlDataAdapter.SelectCommand = New SqlClient.SqlCommand(sSQL,conSQL)
MySqlDataAdapter.Fill(MyDataSet)
And the other here...
MySqlCommand.ExecuteReader
I think you should get rid of the Adapter and DataSet and stick to MySqlCommand since I didn't see your code really using them anyways. Also, you need to dispose MySqlCommand and its DataReader once you're done using them. Not doing so would cause a database connection "leak" (for a database like Access, there are only a finite number of connections that can be made so this is important). Dispose them before you dispose the connection.
[edit]
Oops. I just noticed that you are closing the DataReader. You just need to dispose the MySqlCommand then.
[/edit]
-- modified at 15:04 Wednesday 26th October, 2005
|
|
|
|
|
that's great ..
thank u for ur support
|
|
|
|
|
Hi,
I need a hand. What I need to do is to read a word from a file (this I can do). Then I need to get my program to remove all duplicates from the word. After that I need to load that into a string of textboxes and then to add the alphabet starting from the last letter of the word.
e.g
1. Load the word mememe
2. Strip the duplicates so the final word would be me
3. Insert into textboxes and add alphabet e.g mefghijklnopqrstuvwxyzabcd
Thanks in advance
Stevelam
|
|
|
|
|
Steve...
You didn't specify in the specs whether or not the removal of duplicate letters, and the appending of the alphabet was to be case sensitive. The functions I wrote are both case sensitive.
Download this Visual Studio project from my web site.
http://www.2goodsoftware.com/snippets/duplicate letters.zip
When you run the project in VS, type any string into the textbox and click the button (neither control is appropriately named or initialized since the project is just a test bed). The modified string will be displayed in a message box.
There are two functions ... RemoveDupLetters and AddAlphabet. Copy both functions and paste them into a module (for global scope) in your project.
If I can be of further help, please let me know.
George
|
|
|
|
|
Thats great, thanks. The only problem is the fact that if I put in hello it gives me helopqrstuvwxyz but really I could do with helopqrstuvwxyzacbdfgijkmn
Thanks again for the quick responce.
Steve
|
|
|
|
|
I though the idea was to remove duplicate letters ... as in the second L in hello? Mayhe I missed something. Anyway, your welcome.
|
|
|
|
|
Sorrry I should have said that I needed the whole alphabet in the end, just that it started after the last letter and didnt have any duplicates. Hope you can help. Thanks once again.
Steve
-- modified at 14:35 Wednesday 26th October, 2005
|
|
|
|
|
Steve...
The plot thickens. To ensure that I fully understand what the specs are, please reply with the entire string you expect to get when you enter "hello".
|
|
|
|
|
hellow to all ..
i had read the following artical
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnword2k2/html/odc_wdoverride.asp
on how to overide a command in office word and other office programs ..
but there are plenty of things that i didn't understand ...
like , where do i put Subroutines ?
and how the Override.exe file is related to all this ...
i will be thankful if can anybody help ...
thank's
byebye
-- modified at 5:42 Wednesday 26th October, 2005
|
|
|
|
|
hi,
i m using data grid...how it is possible that data grid does not display null if database does not have value for that perticular column.
i need to print datagrid,
its very urgent please help me.
|
|
|
|
|
Me.columnname.NullText = ""
|
|
|
|
|
i don't know much abt crystal report.i have installed vb.net.as i know with that it'll automatically install crystal report.but every time when i open vb.net it's telling that crystal report should register.
although i have seperate crystal report setup and serial.(have not installed.because it,s there with vb.net)
just i wrote a simple program to use crystal.it was ok.working
but it's telling your crystal report key has expaired.
i have these questions?pls anyone can help me
* how to enter unlock code for crystal report with .net
* if we have registered copy, ones we install system in a machine which have no crystal report what we should we do to work report
* will that also expired
* if i install frame work, will it only be enough to work crystal with machine thats doesn't have .net and crystal report installed
pls help me
amilapradeep2004@yahoo.com
amilapradeep@gmail.com
sri lanka
|
|
|
|
|
Why don't you install the seperate CR version you have there ?
amila pradeep wrote: if i install frame work, will it only be enough to work crystal with machine thats doesn't have .net and crystal report installed
I doubt it. You should try it and see. I'd have expected the compiler to copy whatever you need into the bin dir though.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thanks
if i copy dll where should i copy those
|
|
|
|
|
It depends. Windows/System32 will work, but in theory, we're supposed to put dlls in the same dir as our app in .NET, which will also work.
Christian Graus - Microsoft MVP - C++
|
|
|
|