util

原创
2018/08/08 07:19
阅读数 48

' 当日是否为休日

Public g_IsHoliday As Boolean

' 当前时间 年月日

Public g_Date As String

' 当前时间

Public g_WeekDay As String

' 当前时间 星期几

Public g_Day As String

' 当前文件的路径

Public g_Path As String

' 主机名

Public g_LocalHostName As String

' 获得当前用户的机器名

Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, _

nSize As Long) As Long

' 获得当前用户登录用户名

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _

(ByVal lpBuffer As String, nSize As Long) As Long

'* 注释内容,建立结构体,用于按时间单位保存获取的系统时间。

Private Type SYSTEMTIME

wYear As Integer

wMonth As Integer

wDayOfWeek As Integer

wDay As Integer

wHour As Integer

wMinute As Integer

wSecond As Integer

wMilliseconds As Integer

End Type

' 空格

Public Const SPACE = " "

' 逗号

Public Const COMMA = ","

'template相关

Public Const Template_Dir = "\TEMPLATE\"

Public Const case1 = "部件进度跟踪"

Public Const zsFileName = "暂收报警"

Public Const ysFileName = "验收报警"

Public Const SheetName1 = "仓库品"

Public Const SheetName2 = "临购品"

Public Const SheetName3 = "一般外协品"

Public Const SheetName4 = "整体外协品"

Public Const SheetName5 = "特殊手配"

'路径

Public Const Send_Dir = "\TOSEND\"

' Config 文件名

Public Const Config_FileName = "Config"

' 文件后缀名

Public Const File_ExtentionName = ".xls"

' Config 文件内容

Public Const Start_Row = 4

Public Const Start_Col = 2

Public Const END_COL = 12

' Config 文件列号

Public Const C_NO = 1

Public Const C_FILENAME = 2

Public Const C_TYPE = 3

Public Const C_RATE = 4

Public Const C_QUERY = 5

Public Const C_SEND_TO = 6

Public Const C_SEND_CC = 7

Public Const C_SEND_BCC = 8

Public Const C_SEND_FROM = 9

Public Const C_SEND_TITLE = 10

Public Const C_SEND_CONTENT = 11

Public Const C_ISCREATE = 12

' Config 文件执行种类

Public Const Type_Day = "DAY"

Public Const Type_Week = "WEEK"

Public Const Type_Month = "MONTH"

'************************************************************************************************

'* 功能 取得当前时间的日期

'* 参数

'* 返回值: YYYY-MM-DD

'* 备注

'************************************************************************************************

Public Sub Get_Date()

Dim strDay As String

strDay = DateTime.Date

g_Date = strDay

End Sub

'************************************************************************************************

'* 功能 取得当前时间的日期

'* 参数

'* 返回值: DD

'* 备注

'************************************************************************************************

Public Sub Get_Day()

Dim strDay As String

strDay = DateTime.Day(Now())

g_Day = strDay

End Sub

'************************************************************************************************

'* 功能 取得当前时间的WeekDay

'* 参数

'* 返回值: 1,2,3,4,5,6,7

'* 备注

'************************************************************************************************

Public Sub Get_WeekDay()

Dim strWeekDay As String

strWeekDay = DateTime.weekday(Now(), vbMonday)

g_WeekDay = strWeekDay

End Sub

'************************************************************************************************

'* 功能 取得本文件路径

'* 参数

'* 返回值:

'* 备注

'************************************************************************************************

Public Function Get_Path() As String

g_Path = ThisWorkbook.Path

End Function

'************************************************************************************************

'* 功能 :获得当前的机器名称

'* 参数

'* 返回值:

'* 备注

'************************************************************************************************

Public Sub Get_LocalHostName() '

Dim Comp_Name_B As String * 255

GetComputerName Comp_Name_B, Len(Comp_Name_B)

g_LocalHostName = Left(Comp_Name_B, InStr(Comp_Name_B, Chr(0)) - 1)

End Sub

展开阅读全文
打赏
0
0 收藏
分享

作者的其它热门文章

加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部