Click here to Skip to main content
15,896,606 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: A validation information inside a zip file Pin
Dave Kreskowiak22-Jul-15 3:53
mveDave Kreskowiak22-Jul-15 3:53 
GeneralRe: A validation information inside a zip file Pin
satc26-Jul-15 0:11
satc26-Jul-15 0:11 
GeneralRe: A validation information inside a zip file Pin
Dave Kreskowiak26-Jul-15 3:39
mveDave Kreskowiak26-Jul-15 3:39 
QuestionHelp with datetime Pin
jkirkerx21-Jul-15 10:58
professionaljkirkerx21-Jul-15 10:58 
AnswerRe: Help with datetime Pin
Dave Kreskowiak21-Jul-15 11:56
mveDave Kreskowiak21-Jul-15 11:56 
GeneralRe: Help with datetime Pin
jkirkerx21-Jul-15 13:05
professionaljkirkerx21-Jul-15 13:05 
SuggestionRe: Help with datetime Pin
Ralf Meier21-Jul-15 21:28
mveRalf Meier21-Jul-15 21:28 
SuggestionRe: Help with datetime Pin
Richard Deeming22-Jul-15 1:40
mveRichard Deeming22-Jul-15 1:40 
The DateAdd and DateSerial functions are VB-specific methods intended to provide some level of backwards-compatibility with VB6. They're not particularly efficient, and don't offer anything that the built-in methods on the DateTime type can't do. You should try to avoid using them in any new code.

There's a slight quirt with DateSerial where the month and day parameters can be outside of the valid range - for example, your DateStop passes 0 as the day parameter. If required, you can replicate this behaviour by starting with the 1st January and adding the months and days:
VB.NET
' Instead of:
DateSerial(year, month, day)
' use: (for valid month and day)
New DateTime(year, month, day)
' or: (for valid month, invalid day)
New DateTime(year, month, 1).AddDays(day - 1)
' or: (for invalid month and day)
New DateTime(year, 1, 1).AddMonths(month - 1).AddDays(day - 1)


For DateAdd, the equivalent depends on the date interval you're adding:
VB.NET
' Year:
dateValue.AddYears(number)
' Quarter:
dateValue.AddMonths(number * 3)
' Month:
dateValue.AddMonths(number)
' DayOfYear, Weekday, Day:
dateValue.AddDays(number)
' WeekOfYear:
dateValue.AddDays(number * 7)
' Hour:
dateValue.AddHours(number)
' Minute:
dateValue.AddMinutes(number)
' Second:
dateValue.AddSeconds(number)


For the periods you're using:
VB.NET
' Current day:
Dim todayStart As DateTime = DateTime.Today
Dim todayEnd As DateTime = todayStart.AddDays(1).AddSeconds(-1)

' Current month:
Dim monthStart As New DateTime(DateTime.Today.Year, DateTime.Today.Month, 1)
Dim monthEnd As DateTime = monthStart.AddMonths(1).AddSeconds(-1)

' Current year:
Dim yearStart As New DateTime(DateTime.Today.Year, 1, 1)
Dim yearEnd As DateTime = yearStart.AddYears(1).AddSeconds(-1)




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: Help with datetime Pin
jkirkerx22-Jul-15 6:00
professionaljkirkerx22-Jul-15 6:00 
QuestionVb.net - Datagridview not populated Pin
Marcus Genovese16-Jul-15 23:45
Marcus Genovese16-Jul-15 23:45 
AnswerRe: Vb.net - Datagridview not populated Pin
Simon_Whale17-Jul-15 0:31
Simon_Whale17-Jul-15 0:31 
GeneralRe: Vb.net - Datagridview not populated Pin
Marcus Genovese17-Jul-15 0:43
Marcus Genovese17-Jul-15 0:43 
QuestionAttempted to read or write protected memory. This is often an indication that other memory is corrupt in vb.net Pin
melbin mp16-Jul-15 3:58
melbin mp16-Jul-15 3:58 
AnswerRe: Attempted to read or write protected memory. This is often an indication that other memory is corrupt in vb.net Pin
Wes Aday16-Jul-15 4:37
professionalWes Aday16-Jul-15 4:37 
AnswerRe: Attempted to read or write protected memory. This is often an indication that other memory is corrupt in vb.net Pin
Dave Kreskowiak16-Jul-15 15:53
mveDave Kreskowiak16-Jul-15 15:53 
QuestionIEnumerable(of, DateTime, ToString Format Pin
jkirkerx13-Jul-15 10:56
professionaljkirkerx13-Jul-15 10:56 
AnswerRe: IEnumerable(of, DateTime, ToString Format Pin
Dave Kreskowiak13-Jul-15 12:04
mveDave Kreskowiak13-Jul-15 12:04 
GeneralRe: IEnumerable(of, DateTime, ToString Format Pin
jkirkerx13-Jul-15 12:25
professionaljkirkerx13-Jul-15 12:25 
QuestionNeed to talk to USB serial adapter but no port data available on laptop Pin
KarltheSaabNut13-Jul-15 5:37
professionalKarltheSaabNut13-Jul-15 5:37 
AnswerRe: Need to talk to USB serial adapter but no port data available on laptop Pin
Michael_Davies13-Jul-15 5:48
Michael_Davies13-Jul-15 5:48 
GeneralRe: Need to talk to USB serial adapter but no port data available on laptop Pin
KarltheSaabNut13-Jul-15 6:13
professionalKarltheSaabNut13-Jul-15 6:13 
GeneralRe: Need to talk to USB serial adapter but no port data available on laptop Pin
Michael_Davies13-Jul-15 6:19
Michael_Davies13-Jul-15 6:19 
GeneralRe: Need to talk to USB serial adapter but no port data available on laptop Pin
KarltheSaabNut13-Jul-15 6:28
professionalKarltheSaabNut13-Jul-15 6:28 
QuestionData Access Layer using Entity Framework 6.0, Record Inserts Pin
jkirkerx12-Jul-15 12:03
professionaljkirkerx12-Jul-15 12:03 
Answer[SOLVED] Pin
jkirkerx12-Jul-15 12:50
professionaljkirkerx12-Jul-15 12:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.