Page 1 of 1
VBA DEBUG NEEDED
Posted: February 7th, 2007, 3:54 pm
by CAROLYNW
There's small VBA project has to debug. A coding helper needed immediately. If you can help, please leave your email. I really appreciate for kinds.
VBA DEBUG NEEDED
Posted: February 7th, 2007, 3:57 pm
by Andrew
Details?
VBA DEBUG NEEDED
Posted: February 7th, 2007, 4:43 pm
by CAROLYNW
As this's project with large file, So the easey thing that I send it out to your mail box. Thanks
VBA DEBUG NEEDED
Posted: February 7th, 2007, 5:08 pm
by CAROLYNW
Where's the wrong with the coding as below? I could not run it properly.Option ExplicitPrivate Sub btnCancel_Click() Unload Me EndEnd SubPrivate Sub btnOK_Click() Dim ctl As Control Dim ct As Control ' Make sure the data boxes have valid dates. For Each ctl In Me.Controls If TypeName(ctl) = "TextBox" Then If ctl.Value = "" Or Not IsDate(ctl) Then MsgBox "Enter valid dates in the text boxes.", _ vbInformation, "Invalid entry" ctl.SetFocus Exit Sub End If End If Next ' Capture the dates. firstDate = txtDate1 lastDate = txtDate2 ' Make sure the beginning date isn't after the ending date. If firstDate >= lastDate Then MsgBox "The beginning date should be before the ending date.", _ vbInformation, "Invalid dates" txtDate1.SetFocus Exit Sub End If 'Make sure the valid data are between 01/2003 and 12/2006. If firstDate < 1 / 2003 Or lastDate > 12 / 2006 Then MsgBox "The valid dates should be between 01/2003 and 12/2006.", _ vbInformation, "Invalid dates" ct.SetFocus Exit Sub End If Unload MeEnd SubPrivate Sub UserForm_Initialize() txtDate1 = "" txtDate2 = ""End Sub
VBA DEBUG NEEDED
Posted: February 8th, 2007, 8:52 am
by cemil
------------------------'Make sure the valid data are between 01/2003 and 12/2006.If firstDate < 1 / 2003 Or lastDate > 12 / 2006 ThenMsgBox "The valid dates should be between 01/2003 and 12/2006.", _vbInformation, "Invalid dates"ct.SetFocusExit SubEnd If--------------------------------------------"1 / 2003 " and "12 / 2006 " are not a date
VBA DEBUG NEEDED
Posted: February 8th, 2007, 7:53 pm
by CAROLYNW
I did change to 1/1/2003, but it still can not run.
VBA DEBUG NEEDED
Posted: February 8th, 2007, 8:15 pm
by AVt
I would always convert dates to values (this is a mess in MS) or use a general routine to getit to a normed version and *never* would use any format related to some display, especiallyif one is not very sure of settings for formats in a) Windows b) Excel.
VBA DEBUG NEEDED
Posted: February 9th, 2007, 12:27 am
by lewishortthemall
QuoteOriginally posted by: AVtI would always convert dates to values (this is a mess in MS) or use a general routine to getit to a normed version and *never* would use any format related to some display, especiallyif one is not very sure of settings for formats in a) Windows b) Excel.Yes ,sometimes the date cell in excel is changed into somthg like that ####### ,that's why there are often bugs.
VBA DEBUG NEEDED
Posted: February 9th, 2007, 8:15 am
by cemil
The "1/1/2003" is not date for VBA. This is only a string.You must use date function or the truth value for the date. The truth value for your date"1/1/2003" is 37622.