hfyj.net
当前位置:首页 >> vBA inputBox 日期 >>

vBA inputBox 日期

Sub test() Dim x x = Application.InputBox("输入年月日", , "2013-2-2") If VBA.IsDate(x) = True Then MsgBox "年份为:" & VBA.Year(x) End IfEnd Sub

VBA语言中,函数InputBox是Visual Basic和VBS中的函数,功能是弹出一个对话框。 Visual Basic for Applications(VBA)是Visual Basic的一种宏语言,是微软开发出来在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。主要能用来扩展Windo...

Sub protect()On Error Resume NextDim a As Stringa = InputBox("请输入登陆密码", "管理登陆")If a = "ABC" Then Sheet3.Visible = xlSheetVisible Sheet3.Activate MsgBox "欢迎回来"ElseIf StrPtr(a) 0 Then MsgBox "密码错误"Else EndEnd I...

Private Sub iCheckGs() '--------验证密码 Dim iPsw$, i&, tmp iPsw = " " '"300029" Do tmp = InputBox( _ "系统温馨提醒:" & Chr(10) & Chr(10) & _ "非专业用户请点击{取消}退出!" & Chr(10) & Chr(10) & _ "请输入密码(您还有 " & 3 -...

下面是一个EXCEL里面的例子,供参阅。 ----------------------------------------------------------------------- Option Explicit 'API宣告 Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As S...

Sub dd()on error resume nextDow = InputBox("请输入不存在的工作称的名称")if worksheets(cstr(w)).name ="" then msgbox "不存在这个名称的工作表"else exit doend ifLoopEnd Sub

Sub sdfa() myStr = InputBox("请输入代码的标题") Select Case VBA.LCase(myStr) Case "a" MsgBox "你" Case "b" MsgBox "我" Case "c" MsgBox "他" Case Else MsgBox "error" End Select End Sub

Public Sub 添加目录()Dim WJj As String, i As Byte, Lj As StringDim CXrng As RangeWJj = InputBox("请输入文件夹名称")Fh:i = 0If WJj = "" Then EndFor Each CXrng In ActiveSheet.UsedRange If CXrng.Value = WJj Then i = 1 Lj = Dir("C:...

你可以把inputbox赋给一个变量,通过变量值来检测用户是不点了取消,取消以后变量就是空值"",如果过去到空值就 exit sub

Sub s() Dim a(10) For i = 1 To 10 a(i) = Val(InputBox("请输入第" & i & "个数:")) Next For i = 1 To 9 For j = 9 To i Step -1 If a(j) > a(j + 1) Then tmp = a(j) a(j) = a(j + 1) a(j + 1) = tmp End If Next: Next For i = 1 To 10 t ...

网站首页 | 网站地图
All rights reserved Powered by www.hfyj.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com