update,
This commit is contained in:
75
abc2022d/task1/ticket0002/Common.bas
Normal file
75
abc2022d/task1/ticket0002/Common.bas
Normal file
@@ -0,0 +1,75 @@
|
||||
Attribute VB_Name = "Common"
|
||||
|
||||
Option Explicit
|
||||
|
||||
Global CURRENT_DIR As String
|
||||
|
||||
Function getDateFrRaceCardLink(ByVal in_str As String)
|
||||
' https://racing.hkjc.com/racing/information/English/Racing/Racecard.aspx?RaceDate=2024/04/24&Racecourse=HV&RaceNo=2
|
||||
Dim s_date, s_loc, s_race_num As String
|
||||
s_date = Split(Split(in_str, "=")(1), "&")(0)
|
||||
s_loc = Split(Split(in_str, "=")(2), "&")(0)
|
||||
s_race_num = Split(in_str, "=")(3)
|
||||
|
||||
getDateFrRaceCardLink = Array(s_date, s_loc, s_race_num)
|
||||
End Function
|
||||
|
||||
Function readCell(cell_address As String)
|
||||
Dim temp As String
|
||||
temp = Worksheets("Sheet1").Range(cell_address).value
|
||||
readCell = temp
|
||||
End Function
|
||||
|
||||
Function writeCell(cell_address As String, content As String)
|
||||
'write cell according to cell_address and content
|
||||
Worksheets("Sheet1").Range(cell_address).value = content
|
||||
|
||||
writeCell = content
|
||||
End Function
|
||||
|
||||
|
||||
Function ResetSheet()
|
||||
Worksheets("Sheet1").Range("A3:AC200").ClearContents
|
||||
End Function
|
||||
|
||||
|
||||
Function TidySheet()
|
||||
Worksheets("Sheet1").Range("OK1:OK200").ClearContents
|
||||
|
||||
'widen column width
|
||||
Worksheets("Sheet1").Range("A2:DF200").Columns.AutoFit
|
||||
|
||||
' align text to center
|
||||
Worksheets("Sheet1").Range("A2:DF200").HorizontalAlignment = xlCenter
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Function ParseDDMMYYYY(input_string As String)
|
||||
Dim s_day As String
|
||||
Dim s_month As String
|
||||
Dim s_year As String
|
||||
|
||||
s_day = Split(input_string, "/")(0)
|
||||
s_month = Split(input_string, "/")(1)
|
||||
s_year = Split(input_string, "/")(2)
|
||||
|
||||
ParseDDMMYYYY = DateSerial(CInt(s_year), CInt(s_month), CInt(s_day))
|
||||
End Function
|
||||
|
||||
Sub DisableScreenUpdate
|
||||
Application.ScreenUpdating = False 'disable screen updating
|
||||
Application.Calculation = xlCalculationManual 'disable automatic calculation
|
||||
Application.EnableEvents = False 'disable event handling
|
||||
Application.DisplayAlerts = False 'disable alerts
|
||||
|
||||
end sub
|
||||
|
||||
|
||||
sub ResumeScreenUpdate
|
||||
Application.ScreenUpdating = True 'enable screen updating
|
||||
Application.Calculation = xlCalculationAutomatic 'enable automatic calculation
|
||||
Application.EnableEvents = True 'enable event handling
|
||||
Application.DisplayAlerts = True 'enable alerts
|
||||
|
||||
end sub
|
Reference in New Issue
Block a user