Private Sub a week ahead of ()
Dim date2 As Date=DateTimePicker2. Text
Dim nian, make, ri As Integer
Ri=date2. Day
Make=date2. The Month
Nian=date2. Year
If ri & gt; 7 Then
Ri=ri - 7
The Else
If make 1=2 Then
Ri=ri + 28-7
Make=2
The Else
If make=make - 1=1 And make=3=make - 1 And make=make - 1=5 And make=make - 1=7 And make==8 make - 1 And make=make - 1=10 And make=1 Then
Ri=ri + 31-7
If make=1 Then
Make=make + 12-1
Nian nian=1
The Else
Make=make - 1
End the If
The Else
Ri=ri + 30-7
If make=1 Then
Make=make + 12-1
Nian nian=1
The Else
Make=make - 1
End the If
End the If
End the If
End the If
DateTimePicker1. Text=nian & amp; - make & amp; - ri
End Sub
CodePudding user response:
Elementary, middle directly with the formula (turn to unified caliber can set of formula, such as Linux under the 1970-01-01)
CodePudding user response:
With the benefits of the formula is: unified caliber, code, don't need to consider the New Year, month, and do not need to consider a leap year, leap month, because the formula itself has fully considered the
, of course, the actual work of engineers, even don't have to set formula, because Microsoft is ready, the ans just directly with adddays (7) or AddWeeks (1)
https://docs.microsoft.com/en-us/dotnet/api/system.globalization.calendar.addweeks? Redirectedfrom=MSDN& View=netframework 4.8 # System_Globalization_Calendar_AddWeeks_System_DateTime_System_Int32_
CodePudding user response:
Elementary school students use accompanied by a guardian CSDN
CodePudding user response:
Thank you, I'll come on efforts
CodePudding user response:
refer to the second floor wanghui0380 response: with the benefits of the formula is: unified caliber, code, don't need to think about New Year's, across the month, at the same time do not need to consider a leap year, leap month, because the formula itself has fully considered the , of course, the actual work of engineers, even don't have to set formula, because Microsoft is ready, the ans just directly with adddays (7) or AddWeeks (1) https://docs.microsoft.com/en-us/dotnet/api/system.globalization.calendar.addweeks? Redirectedfrom=MSDN& View=# System_Globalization_Calendar_AddWeeks_System_DateTime_System_Int32_ netframework 4.8 Thank you, I will become a junior high school students as soon as possible CodePudding user response:
Although is primary school students, some also want to learn and use, such as the big months of judgment can change: If in less than 8 then encountered odd If in greater than 7 then meet even I want to learn the elementary school mathematics have been summed up. CodePudding user response:
Posting at the same time also want to learn how to use the code provided writing instruments, each step is the cornerstone of success, Dim make=10 If (make & lt; 8 And make Mod 2=1) Or (make & gt; 7 And make the Mod 2=0) Then End the If 'it looks much more comfortable? Logic is very clear CodePudding user response:
No watch carefully, this is what to do, write so much, Dim date2 As Date=DateTimePicker2. Text It sure does not need to convert types, DateTimePicker2 you define your own classes CodePudding user response:
Mr, 1 3 5 7 8 10 12 31 days never bad it is, CodePudding user response:
Leap in February treatment separately listed judgment, the judgment leap year when handling leap month, CodePudding user response:
references to the tenth floor wise men know already should good karma response: leap in February treatment separately listed judgment, the judgment leap year when handling leap month, How to get? I am a beginner will not how CodePudding user response:
reference XBodhi. The eighth floor response: didn't watch carefully, this is what to do, write so much, Dim date2 As Date=DateTimePicker2. Text It sure does not need to convert types, DateTimePicker2 you define your own class Not ah, this is a time frame CodePudding user response:
AddWeeks adddays () () under the reference, aaah CodePudding user response:
Dim make=2, 28 nian=2020, yue2= If (make & lt; 8 And make Mod 2=1) Or (make & gt; 7 And make the Mod 2=0) Then End the If If make=2 Then Yue2=IIf (((4=0 And nian nian Mod Mod 100 & gt; 1) Or (nian Mod=0 400)), 29, 28) End the If CodePudding user response:
Of course you can be so write If make=2 Then Yue2=IIf (((4=0 And nian nian Mod Mod 100 & lt;> 400=0, 0) Or nian Mod), 29, 28) End the If In four years'/* leap, one hundred is not a leap, leap again in four hundred, */ If not used to the ternary operator can be instead of the usual judgment type If make=2 Then If ((4=0 And nian nian Mod Mod 100 & lt;> 400=0, 0) Or nian Mod) Then yue2=29 Else yue2=28 End the If The title of another look at your function for one week in advance, then calculate + 7, then write a date + processing function CodePudding user response:
references the wise know already 15 floor should good karma response: , of course, you can write If make=2 Then Yue2=IIf (((4=0 And nian nian Mod Mod 100 & lt;> 400=0, 0) Or nian Mod), 29, 28) End the If In four years'/* leap, one hundred is not a leap, leap again in four hundred, */ If not used to the ternary operator can be instead of the usual judgment type If make=2 Then If ((4=0 And nian nian Mod Mod 100 & lt;> 400=0, 0) Or nian Mod) Then yue2=29 Else yue2=28 End the If Another look at the title of the function you for one week in advance, then calculate + 7, then write a date + handler Thank you, and I want to ask what's monthly and abortion gradient some way CodePudding user response:
Explain what is the gradient, for example, first learning to program is about to get all the concepts clear, CodePudding user response:
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull