Просто еще одна точка зрения
Вместо Nullable вы можете справиться с этим, используя Необязательно
Если вы определите его как Optional BLABLA As Integer
, он будет иметь значение по умолчанию 0
, поэтому, если его пустое или пустое значение u будет иметь значение по умолчанию как 0
..
Вот пример, который я сделал для себя! Это может пригодиться:
Использование:
ProgressInc ProgressBar1 'you can add other options if you want as shown below
'ProgressInc ProgressBar1, 500, 50, 25, True
'I always change Min value to 1 in my ProgressInc so if you even choose it as 0 it still gonna be 1
так же работает
Dim TheThing As Long
ProgressInc ProgressBar1 ,TheThing
'See no definition about TheThing except being Long type
'cause of this its value is 0
Sub:
Public Sub ProgressInc(ProgressBarName As ProgressBar, Optional Max As Long, Optional Min As Long, Optional Inc As Long, Optional Continues As Boolean = False)
Dim Recent As Long
On Err GoTo ProgressBarErr
ProgressBarName.ShowWhatsThis
DoEvents
'Maximum ProgressBar Value
If Max <> 0 Then
ProgressBarName.Max = Max
Else
Max = 100
ProgressBarName.Max = Max
End If
'Minimum ProgressBar Value
If Min <> 0 Then
ProgressBarName.Min = Min
Else
Min = 1
ProgressBarName.Min = Min
End If
If Inc <> 0 Then Inc = Inc Else Inc = 1
'When the ProgressBar value is at Maximum
'Return to the Minimum value
If Continues = True And ProgressBarName.Value = Max Then
ProgressBarName.Value = Min
End If
'Checkout Recent progress (pre calculate bar value)
Recent = ProgressBarName.Value + Inc
If Recent >= Max Then
'Recent value is higher than or equals to Max value
'to avoid errors caused by this issue Value should equal to Max
ProgressBarName.Value = Max
ElseIf Recent < Max Then
'Recent(pre calculated bar value) is lower than Max
'So nothing wrong here, proceed..
ProgressBarName.Value = ProgressBarName.Value + Inc
End If
Exit Sub
ProgressBarErr:
'ProgressBar error report.
MsgBox "With " & Err.Number & " number : '" & Err.Description & "' error occured. "
End Sub
см. Там я получаю Min, Max, Inc As Long и когда я не определяю их, они имеют 0
в качестве значения по умолчанию.