用VB实现图形化日历
发布网友
发布时间:2022-05-29 21:47
我来回答
共2个回答
热心网友
时间:2024-10-01 18:18
'新建工程,添加command1,复制粘贴下段代码
Private Sub Command1_Click() '导出
On Error GoTo adderr
Dim d As Date
d = InputBox("输入日期:年月间以 / 或 - 连接。")
c = cale(d)
Print c
X = InputBox("输入文件名:")
Open "c:\" & X & ".txt" For Output As #1
Print #1, c
Close #1
Print "※由" & d & "生成的日历已保存在C:\" & X & ".txt"
adderr: Exit Sub
End Sub
Private Sub Form_Load()
Me.AutoRedraw = True
Print cale(Date)
End Sub
Function cale(d As Date) As String
Select Case Month(d) '计算该月天数ds
Case 1, 3, 5, 7, 8, 10, 12
ds = 31
Case 2
If ((year(d) Mod 4 = 0 And year(d) Mod 100 <> 0) Or year(d) Mod 400 = 0) Then
ds = 29
Else
ds = 28
End If
Case 4, 6, 9, 11
ds = 30
End Select
cale = "Calendar" & vbCrLf & Format(d, "mmmm") & vbCrLf & String(53, "-") & vbCrLf '日历表头
For i = 1 To 7
cale = cale & Choose(i, "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat") & vbTab
Next
cale = cale & vbCrLf
For i = 1 To Weekday(DateSerial(year(d), Month(d), 1)) - 1 '空出当月一号星期数之前的位置
cale = cale & vbTab
Next
For i = 1 To ds '写日历
cale = cale & IIf(i < 10, " ", "") & i
If Weekday(DateSerial(year(d), Month(d), i)) Mod 7 = 0 Then
cale = cale & vbCrLf
Else
cale = cale & vbTab
End If
Next
'日历表尾
cale = cale & vbCrLf & "今天是:" & Format(d, "long date") & ",星期" & Choose(Weekday(d), "日", "一", "二", "三", "四", "五", "六") & vbCrLf & "当前时间是:" & Format(Now, "hh时mm分ss秒")
End Function
热心网友
时间:2024-10-01 18:19
Mail to happyq6@163.com.
刚才是你Hi我的不?
给个油箱,明天发给你。
vb程序中 像图片一样的 日期下拉菜单式怎么弄的?求高手指点迷津!希望...
再在窗体上划一个 “日历控件”(Calendar1)再写点代码就可以了。以下是我写的一点代码,希望有助于你:Private Sub Text2_GotFocus()Calendar1.Visible = True Calendar1.SetFocus End Sub Private Sub Calendar1_Click()Text2 = Calendar1.Value Calendar1.Visible = False End Sub 你图上的...
跪求一个vb的日历程序,界面做成这样的,非常感谢 下次有分了补上_百度...
Private Sub Form_Load()While 1 Dim y As Integer, m As Integer, d As Integer, s As Date, x As Integer, r As String y = InputBox("请输入年份", , Format(Now, "yyyy"))m = InputBox("请输入月份", , Format(Now, "mm"))d = InputBox("请输入日期", , Format(Now, ...
怎样利用VB编码设置一个日历,可以让2月显示28天或29天
Private Sub Combo日期_click(Index As Integer)If Index = 1 Then Combo日期(2).Clear Select Case Combo日期(1).Text Case 1, 3, 5, 7, 8, 10, 12 For j = 1 To 31 Combo日期(2).AddItem j Next j Case 4, 6, 9, 11 For j = 1 To 30 Combo日期(2).AddItem j Next j ...
vb编程里,如何实现点击窗体中一个文本框出现日历控件,然后可以选择相应...
首先在默认form1窗体上画一个文本框text1、再画一个日历控件MonthView1,记得是MonthView1控件,你自己排列好它们两个的位置即可,一切都按默认(不用改属性)。然后复制以下代码到form1的代码窗口里运行即可看到结果啦(如图):Private Sub Form_Load()MonthView1.Visible = False End Sub Private Sub ...
求一个VB万年历的程序
lblD(R).BackColor = vbWhite Next \\\'Shape1.Visible = False Dim qaa As Integer Dim t, d As Integer Dim e As Date e = DateSerial(YearV, MonthV, 1)qaa = DatePart("w", e)\\\'e = "1" & "-" & CStr(strMoto(MonthV)) & "-" & YearV \\\'qaa = DatePart("...
用VB中的日历(DTPicker) 和datagrid控件实现:点击日历日期在datagrid...
Private Sub FormLoad()Dim RecordDate As Recordset ’记录集对象,记录日期查询结果 Dim strSQL As String Dim MaxDate As Date '记录中日期的最大值 Dim MinDate As Date '记录中日期的最小指 strSQL = "select max(Date) as nMax,min(Date) as nMin from Table"Set ...
vb怎么制作日历
Sub Command1_Click()Dim d As Date Dim y As Integer Dim start As Date Dim length As Integer d = CDate(Text1.Text)y = year(d)start = CDate(y & "-01-01")length = DateDiff("d", start, d) + 1 MsgBox ("是" & y & "年的第" & length & "天!")End Sub ...
VB问题(计算农历中nonglidata(n)是怎么得出来的)
碰上农历闰月怎么办呢?比如,日历上1922年是农历闰五月的。在nonglidata上,你会发现有很多大于4095的数值,比如1922年是NongliData(1)=333387,二进制是1010001011001001011,1922年农历有13个月(包括农历闰月),去掉头101000,1011001001011是13个月份数据,而闰几月就在101000中保存,删掉后3个0,101就...
求用vb做万年历 要求输入一个日期 得到星期节日星座节气
另外的农历,是更好地做 用的printf打印功能目录,切换来完成调用子函数很多次了,再加上大循环 日历显示,这是相对简单的,是计算的一年的第一天是星期可以 原则:第1年1月1日(星期一),计算这天的第一天,年1月1日,1的AD,除以7的中间的,其余的是周。一年365天,364正好是7的倍数,那么...
vb程序界面这样子的日期下拉菜单怎么弄啊?希望从控件到需修改的控件内容...
最简单的就是直接添加部件“Microsoft 日历控件”Calendar 然后把日历控件Calendar拖入摆放在Text文本框下面,Calendar加入如下代码 Private Sub Calendar1_Click()Text1.Text = Calendar1.Year & -Calendar1.Month & -Calendar1.Day Calendar1.Visible = False End Sub 然后在文本框Text加入如下代码 Privat...