Serving the Quantitative Finance Community

 
User avatar
CAROLYNW
Topic Author
Posts: 0
Joined: July 16th, 2006, 1:49 pm

VBA DEBUG NEEDED

February 7th, 2007, 3:54 pm

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.
 
User avatar
Andrew
Posts: 0
Joined: August 20th, 2001, 7:33 pm

VBA DEBUG NEEDED

February 7th, 2007, 3:57 pm

Details?
 
User avatar
CAROLYNW
Topic Author
Posts: 0
Joined: July 16th, 2006, 1:49 pm

VBA DEBUG NEEDED

February 7th, 2007, 4:43 pm

As this's project with large file, So the easey thing that I send it out to your mail box. Thanks
 
User avatar
CAROLYNW
Topic Author
Posts: 0
Joined: July 16th, 2006, 1:49 pm

VBA DEBUG NEEDED

February 7th, 2007, 5:08 pm

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
 
User avatar
cemil

VBA DEBUG NEEDED

February 8th, 2007, 8:52 am

------------------------'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
 
User avatar
CAROLYNW
Topic Author
Posts: 0
Joined: July 16th, 2006, 1:49 pm

VBA DEBUG NEEDED

February 8th, 2007, 7:53 pm

I did change to 1/1/2003, but it still can not run.
 
User avatar
AVt
Posts: 90
Joined: December 29th, 2001, 8:23 pm

VBA DEBUG NEEDED

February 8th, 2007, 8:15 pm

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.
 
User avatar
lewishortthemall
Posts: 0
Joined: January 10th, 2007, 6:58 pm

VBA DEBUG NEEDED

February 9th, 2007, 12:27 am

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.
Last edited by lewishortthemall on February 8th, 2007, 11:00 pm, edited 1 time in total.
 
User avatar
cemil

VBA DEBUG NEEDED

February 9th, 2007, 8:15 am

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.