r55Hitman Табличными значениями лучше оперировать в табличном редакторе -- который Excel.
Далее, принципиально избавиться от сложности не получится -- либо будет сложно заполнять исходные данные для простой проверки (а такую можно сделать), либо будет сложная проверка.
Цитата: сам пытался через иф зен го ту, но очень объемный текст получается(
Лучше через трёхэтажный Select Case
Код будет несколько понятнее.
Цитата: и также через масивы но ниче толком не придумал, помогите пожалуйста
Простым и тривиальным способом через массивы завести вряд ли получится. Надо трёхмерный массив объявлять; для каждого измерения либо свой набор констант, либо свой Enum; а потом всё равно будет трёхэтажный If/Select Case.
И о простой проверке -- навскидку придумался вариант с коллекциями, но не думаю, что им стоит пользоваться (хоть он и работает)
[more]
Код: Option Explicit
Private data_storage As Collection
Private Sub Form_Load()
On Error GoTo ErrorHandler
InitializeData
Dim found_data As String
Dim value1 As String, value2 As String, value3 As String
value1 = "100" 'Text1.Text
value2 = "80" 'Text2.Text
value3 = "40" 'Text3.Text
found_data = FindData(value1, value2, value3)
MsgBox found_data
value1 = "100" 'Text1.Text
value2 = "20" 'Text2.Text
value3 = "80" 'Text3.Text
found_data = FindData(value1, value2, value3)
MsgBox found_data
value1 = "100" 'Text1.Text
value2 = "80" 'Text2.Text
value3 = "200" 'Text3.Text
found_data = FindData(value1, value2, value3)
MsgBox found_data
value1 = "500" 'Text1.Text
value2 = "80" 'Text2.Text
value3 = "200" 'Text3.Text
found_data = FindData(value1, value2, value3)
MsgBox found_data
value1 = "400" 'Text1.Text
value2 = "400" 'Text2.Text
value3 = "200" 'Text3.Text
found_data = FindData(value1, value2, value3)
MsgBox found_data
ErrorHandler:
End
End Sub
Private Sub InitializeData()
On Error GoTo ErrorHandler
Set data_storage = New Collection
With data_storage
.Add New Collection, "100"
With .Item(.Count)
.Add New Collection, "40"
With .Item(.Count)
.Add "0.060", "40"
.Add "0.057", "60"
.Add "0.054", "80"
'.Add "", "100"
'.Add "", "120"
'.Add "", "160"
'.Add "", "200"
End With
.Add New Collection, "60"
With .Item(.Count)
.Add "0.062", "40"
.Add "0.060", "60"
.Add "0.058", "80"
'.Add "", "100"
'.Add "", "120"
'.Add "", "160"
'.Add "", "200"
End With
.Add New Collection, "80"
With .Item(.Count)
.Add "0.064", "40"
.Add "0.061", "60"
.Add "0.060", "80"
'.Add "", "100"
'.Add "", "120"
'.Add "", "160"
'.Add "", "200"
End With
.Add New Collection, "100"
With .Item(.Count)
.Add "0.068", "40"
.Add "0.064", "60"
.Add "0.063", "80"
'.Add "", "100"
'.Add "", "120"
'.Add "", "160"
'.Add "", "200"
End With
.Add New Collection, "125"
With .Item(.Count)
.Add "0.074", "40"
.Add "0.071", "60"
.Add "0.070", "80"
'.Add "", "100"
'.Add "", "120"
'.Add "", "160"
'.Add "", "200"
End With
.Add New Collection, "160"
With .Item(.Count)
.Add "0.089", "40"
.Add "0.088", "60"
'.Add "", "80"
'.Add "", "100"
'.Add "", "120"
'.Add "", "160"
'.Add "", "200"
End With
End With
.Add New Collection, "125"
With .Item(.Count)
.Add New Collection, "60"
With .Item(.Count)
.Add "0.067", "40"
.Add "0.063", "60"
.Add "0.061", "80"
.Add "0.060", "100"
'.Add "", "120"
'.Add "", "160"
'.Add "", "200"
End With
.Add New Collection, "80"
With .Item(.Count)
.Add "0.068", "40"
.Add "0.064", "60"
.Add "0.063", "80"
.Add "0.061", "100"
'.Add "", "120"
'.Add "", "160"
'.Add "", "200"
End With
.Add New Collection, "100"
With .Item(.Count)
.Add "0.072", "40"
.Add "0.068", "60"
.Add "0.067", "80"
.Add "0.064", "100"
'.Add "", "120"
'.Add "", "160"
'.Add "", "200"
End With
.Add New Collection, "125"
With .Item(.Count)
.Add "0.079", "40"
.Add "0.075", "60"
.Add "0.072", "80"
.Add "0.071", "100"
'.Add "", "120"
'.Add "", "160"
'.Add "", "200"
End With
.Add New Collection, "160"
With .Item(.Count)
.Add "0.096", "40"
.Add "0.092", "60"
.Add "0.089", "80"
.Add "0.086", "100"
'.Add "", "120"
'.Add "", "160"
'.Add "", "200"
End With
End With
.Add New Collection, "160"
With .Item(.Count)
.Add New Collection, "100"
With .Item(.Count)
.Add "0.078", "40"
.Add "0.074", "60"
.Add "0.071", "80"
.Add "0.070", "100"
'.Add "", "120"
'.Add "", "160"
'.Add "", "200"
End With
.Add New Collection, "125"
With .Item(.Count)
.Add "0.086", "40"
.Add "0.079", "60"
.Add "0.077", "80"
.Add "0.075", "100"
'.Add "", "120"
'.Add "", "160"
'.Add "", "200"
End With
.Add New Collection, "160"
With .Item(.Count)
.Add "0.103", "40"
.Add "0.099", "60"
.Add "0.095", "80"
.Add "0.091", "100"
'.Add "", "120"
'.Add "", "160"
'.Add "", "200"
End With
End With
.Add New Collection, "200"
With .Item(.Count)
.Add New Collection, "125"
With .Item(.Count)
.Add "0.099", "40"
.Add "0.092", "60"
.Add "0.091", "80"
.Add "0.089", "100"
.Add "0.086", "120"
.Add "0.084", "160"
'.Add "", "200"
End With
.Add New Collection, "160"
With .Item(.Count)
.Add "0.127", "40"
.Add "0.123", "60"
.Add "0.117", "80"
.Add "0.115", "100"
.Add "0.115", "120"
.Add "0.112", "160"
'.Add "", "200"
End With
.Add New Collection, "200"
With .Item(.Count)
.Add "0.294", "40"
.Add "0.290", "60"
.Add "0.277", "80"
.Add "0.283", "100"
.Add "0.281", "120"
.Add "0.280", "160"
'.Add "", "200"
End With
End With
.Add New Collection, "250"
With .Item(.Count)
.Add New Collection, "125"
With .Item(.Count)
'.Add "", "40"
.Add "0.109", "60"
.Add "0.103", "80"
.Add "0.102", "100"
.Add "0.099", "120"
.Add "0.095", "160"
'.Add "", "200"
End With
.Add New Collection, "160"
With .Item(.Count)
'.Add "", "40"
.Add "0.136", "60"
.Add "0.130", "80"
.Add "0.129", "100"
.Add "0.124", "120"
.Add "0.123", "160"
'.Add "", "200"
End With
.Add New Collection, "200"
With .Item(.Count)
'.Add "", "40"
.Add "0.308", "60"
.Add "0.294", "80"
.Add "0.290", "100"
.Add "0.288", "120"
.Add "0.284", "160"
'.Add "", "200"
End With
.Add New Collection, "250"
With .Item(.Count)
'.Add "", "40"
.Add "0.328", "60"
.Add "0.322", "80"
.Add "0.319", "100"
.Add "0.316", "120"
.Add "0.309", "160"
'.Add "", "200"
End With
End With
.Add New Collection, "320"
With .Item(.Count)
.Add New Collection, "180"
With .Item(.Count)
'.Add "", "40"
.Add "0.307", "60"
.Add "0.301", "80"
.Add "0.297", "100"
.Add "0.294", "120"
.Add "0.288", "160"
.Add "0.284", "200"
End With
.Add New Collection, "200"
With .Item(.Count)
'.Add "", "40"
.Add "0.322", "60"
.Add "0.319", "80"
.Add "0.314", "100"
.Add "0.308", "120"
.Add "0.304", "160"
.Add "0.300", "200"
End With
.Add New Collection, "250"
With .Item(.Count)
'.Add "", "40"
.Add "0.364", "60"
.Add "0.363", "80"
.Add "0.359", "100"
.Add "0.350", "120"
.Add "0.346", "160"
.Add "0.340", "200"
End With
.Add New Collection, "320"
With .Item(.Count)
'.Add "", "40"
.Add "0.391", "60"
.Add "0.388", "80"
.Add "0.378", "100"
.Add "0.371", "120"
.Add "0.366", "160"
.Add "0.363", "200"
End With
End With
.Add New Collection, "400"
With .Item(.Count)
.Add New Collection, "200"
With .Item(.Count)
'.Add "", "40"
'.Add "", "60"
'.Add "", "80"
'.Add "", "100"
'.Add "", "120"
.Add "0.325", "160"
.Add "0.322", "200"
End With
.Add New Collection, "250"
With .Item(.Count)
'.Add "", "40"
'.Add "", "60"
'.Add "", "80"
'.Add "", "100"
'.Add "", "120"
.Add "0.356", "160"
.Add "0.350", "200"
End With
.Add New Collection, "320"
With .Item(.Count)
'.Add "", "40"
'.Add "", "60"
'.Add "", "80"
'.Add "", "100"
'.Add "", "120"
.Add "0.394", "160"
.Add "0.380", "200"
End With
.Add New Collection, "400"
With .Item(.Count)
'.Add "", "40"
'.Add "", "60"
'.Add "", "80"
'.Add "", "100"
'.Add "", "120"
.Add "0.437", "160"
.Add "0.433", "200"
End With
End With
End With 'data_storage
Exit Sub
ErrorHandler:
'...
End Sub
Private Function FindData(ByVal crit1 As String, ByVal crit2 As String, ByVal crit3 As String) As String
Const DEFAULT_RETURN_DATA As String = "0"
On Error GoTo ErrorHandler
Dim return_data As String: return_data = DEFAULT_RETURN_DATA
return_data = data_storage(crit1)(crit2)(crit3)
FindData = return_data
Exit Function
ErrorHandler:
FindData = DEFAULT_RETURN_DATA
End Function