233 lines
7.0 KiB
QBasic
233 lines
7.0 KiB
QBasic
Attribute VB_Name = "Common_Selector"
|
|
Option Explicit
|
|
' ============================================================
|
|
' Module Name: Common_Selector
|
|
' Module Desc: Build dropdown lists from cache data
|
|
' Module Methods:
|
|
' - BuildTransportList
|
|
' - BuildTodokeList
|
|
' - BuildOufukuList
|
|
' - BuildKoutaiList
|
|
' - BuildKetteiList
|
|
' - BuildHigaitouList
|
|
' - BuildKanshokuList
|
|
' - BuildKenshuList
|
|
' ============================================================
|
|
|
|
' ============================================================
|
|
' Event Handlers
|
|
' ============================================================
|
|
' Create Transport (T) dropdown from Z1 cache
|
|
Public Function BuildTransportList()
|
|
Dim z1Cache As Object: Set z1Cache = GetCache("Z1")
|
|
|
|
Dim dropdownList As String
|
|
Dim key As Variant
|
|
For Each key In z1Cache.Keys
|
|
Dim displayText As String
|
|
displayText = MakeSelect(key, z1Cache(key)(0))
|
|
If dropdownList = "" Then
|
|
dropdownList = displayText
|
|
Else
|
|
dropdownList = dropdownList & "," & displayText
|
|
End If
|
|
Next key
|
|
|
|
BuildTransportList = dropdownList
|
|
End Function
|
|
|
|
' Create Todoke (G) dropdown
|
|
Public Function BuildTodokeList()
|
|
Dim o3Cache As Object: Set o3Cache = GetCache(CACHE_O3)
|
|
|
|
Dim dropdownList As String
|
|
Dim key As Variant
|
|
For Each key In o3Cache.Keys
|
|
Dim displayText As String
|
|
displayText = MakeSelect(key, o3Cache(key)(0))
|
|
If dropdownList = "" Then
|
|
dropdownList = displayText
|
|
Else
|
|
dropdownList = dropdownList & "," & displayText
|
|
End If
|
|
Next key
|
|
BuildTodokeList = dropdownList
|
|
End Function
|
|
|
|
' Create Oufuku (M) dropdown
|
|
Public Function BuildOufukuList()
|
|
Dim oufukuList As Object: Set oufukuList = GetCache("oufukuList")
|
|
|
|
Dim dropdownList As String
|
|
Dim key As Variant
|
|
For Each key In oufukuList.Keys
|
|
Dim displayText As String
|
|
displayText = MakeSelect(key, oufukuList(key)(0))
|
|
If dropdownList = "" Then
|
|
dropdownList = displayText
|
|
Else
|
|
dropdownList = dropdownList & "," & displayText
|
|
End If
|
|
Next key
|
|
BuildOufukuList = dropdownList
|
|
End Function
|
|
|
|
' Create Koutai (N) dropdown
|
|
Public Function BuildKoutaiList()
|
|
Dim koutaiList As Object: Set koutaiList = GetCache("koutaiList")
|
|
|
|
Dim dropdownList As String
|
|
Dim key As Variant
|
|
For Each key In koutaiList.Keys
|
|
Dim displayText As String
|
|
displayText = MakeSelect(key, koutaiList(key)(0))
|
|
If dropdownList = "" Then
|
|
dropdownList = displayText
|
|
Else
|
|
dropdownList = dropdownList & "," & displayText
|
|
End If
|
|
Next key
|
|
BuildKoutaiList = dropdownList
|
|
End Function
|
|
|
|
' Create Kettei (AU) dropdown
|
|
Public Function BuildKetteiList()
|
|
Dim z2Cache As Object: Set z2Cache = GetCache("Z2")
|
|
|
|
Dim dropdownList As String
|
|
Dim key As Variant
|
|
For Each key In z2Cache.Keys
|
|
Dim displayText As String
|
|
displayText = MakeSelect(key, z2Cache(key)(0))
|
|
If dropdownList = "" Then
|
|
dropdownList = displayText
|
|
Else
|
|
dropdownList = dropdownList & "," & displayText
|
|
End If
|
|
Next key
|
|
BuildKetteiList = dropdownList
|
|
End Function
|
|
|
|
' Create Higaitou (AW) dropdown
|
|
Public Function BuildHigaitouList()
|
|
Dim higaitouList As Object: Set higaitouList = GetCache("higaitouList")
|
|
|
|
Dim dropdownList As String
|
|
Dim key As Variant
|
|
For Each key In higaitouList.Keys
|
|
Dim displayText As String
|
|
displayText = MakeSelect(key, higaitouList(key)(0))
|
|
If dropdownList = "" Then
|
|
dropdownList = displayText
|
|
Else
|
|
dropdownList = dropdownList & "," & displayText
|
|
End If
|
|
Next key
|
|
BuildHigaitouList = dropdownList
|
|
End Function
|
|
|
|
' Create Kanshoku (BC) dropdown
|
|
Public Function BuildKanshokuList()
|
|
Dim o2Cache As Object: Set o2Cache = GetCache("O2")
|
|
|
|
Dim dropdownList As String
|
|
Dim key As Variant
|
|
For Each key In o2Cache.Keys
|
|
Dim displayText As String
|
|
displayText = MakeSelect(key, o2Cache(key)(0))
|
|
If dropdownList = "" Then
|
|
dropdownList = displayText
|
|
Else
|
|
dropdownList = dropdownList & "," & displayText
|
|
End If
|
|
Next key
|
|
BuildKanshokuList = dropdownList
|
|
End Function
|
|
|
|
' Create Kenshu dropdown (exclude key = 0)
|
|
Public Sub BuildKenshuDropdown(ws As Worksheet, ByVal columnLetter As String, ByVal rowNum As Long)
|
|
Dim kenshuList As Object: Set kenshuList = GetCache("kenshuList")
|
|
|
|
Dim dropdownList As String
|
|
Dim key As Variant
|
|
For Each key In kenshuList.Keys
|
|
If key <> 0 Then
|
|
Dim displayText As String
|
|
displayText = MakeSelect(key, kenshuList(key)(0))
|
|
If dropdownList = "" Then
|
|
dropdownList = displayText
|
|
Else
|
|
dropdownList = dropdownList & "," & displayText
|
|
End If
|
|
End If
|
|
Next key
|
|
|
|
With ws.Range(columnLetter & rowNum).Validation
|
|
.Delete
|
|
.Add Type:=xlValidateList, Formula1:=dropdownList
|
|
.IgnoreBlank = True
|
|
.InCellDropdown = True
|
|
.InputTitle = ""
|
|
.InputMessage = ""
|
|
End With
|
|
End Sub
|
|
|
|
' Create Tokubetu dropdown
|
|
Public Sub BuildTokubetuDropdown(ws As Worksheet, ByVal columnLetter As String, ByVal rowNum As Long)
|
|
Dim tokubetuList As Object: Set tokubetuList = GetCache("tokubetuList")
|
|
Dim dropdownList As String: dropdownList = ""
|
|
Dim key As Variant
|
|
For Each key In tokubetuList.Keys
|
|
If dropdownList = "" Then
|
|
dropdownList = key
|
|
Else
|
|
dropdownList = dropdownList & "," & key
|
|
End If
|
|
Next key
|
|
|
|
With ws.Range(columnLetter & rowNum).Validation
|
|
.Delete
|
|
.Add Type:=xlValidateList, Formula1:=dropdownList
|
|
.IgnoreBlank = True
|
|
.InCellDropdown = True
|
|
.InputTitle = ""
|
|
.InputMessage = ""
|
|
End With
|
|
End Sub
|
|
|
|
' Create Renraku dropdown
|
|
Public Sub BuildRenrakuDropdown(ws As Worksheet, ByVal columnLetter As String, ByVal rowNum As Long)
|
|
Dim renrakuList As Object: Set renrakuList = GetCache("renrakuList")
|
|
Dim dropdownList As String: dropdownList = ""
|
|
Dim key As Variant
|
|
For Each key In renrakuList.Keys
|
|
If dropdownList = "" Then
|
|
dropdownList = key
|
|
Else
|
|
dropdownList = dropdownList & "," & key
|
|
End If
|
|
Next key
|
|
|
|
With ws.Range(columnLetter & rowNum).Validation
|
|
.Delete
|
|
.Add Type:=xlValidateList, Formula1:=dropdownList
|
|
.IgnoreBlank = True
|
|
.InCellDropdown = True
|
|
.InputTitle = ""
|
|
.InputMessage = ""
|
|
End With
|
|
End Sub
|
|
|
|
' Build dropdown using Caches sheet
|
|
Public Sub BuildDropdownFromCacheNamedRange(ws As Worksheet, columnLetter As String, rowNum As Long, cacheName As String)
|
|
Dim formula As String: formula = GetValidationFormula(cacheName)
|
|
If formula = "" Then Exit Sub
|
|
|
|
With ws.Range(columnLetter & rowNum).Validation
|
|
.Delete
|
|
.Add Type:=xlValidateList, Formula1:=formula
|
|
.IgnoreBlank = True
|
|
.InCellDropdown = True
|
|
End With
|
|
End Sub
|