оператор ветвления

gregi
Дата: 25.11.2006 20:31:11
Подскажите где можно найти подробную инфу по оператору if. То что нашел не помогает
пытаюсь повесить алгоритм проверки штрих кода....
mds_world
Дата: 25.11.2006 20:45:18
Из хелпа к Аксу 2003

If...Then...Else Statement
      

Conditionally executes a group of statements, depending on the value of an expression.

Syntax

If condition Then [statements] [Else elsestatements]

Or, you can use the block form syntax:

If condition Then
[statements]

[ElseIf condition-n Then
[elseifstatements] ...

[Else
[elsestatements]]

End If

The If...Then...Else statement syntax has these parts:

Part Description 
condition Required. One or more of the following two types of expressions: 
  A numeric expression or string expression that evaluates to True or False. If condition is Null, condition 
is treated as False. 
  An expression of the form TypeOf objectname Is objecttype. The objectname is any object reference 
and objecttype is any valid object type. The expression is True if objectname is of the object type 
specified by objecttype; otherwise it is False. 
statements Optional in block form; required in single-line form that has no Else clause. One or more 
statements separated by colons; executed if condition is True. 
condition-n Optional. Same as condition. 
elseifstatements Optional. One or more statements executed if associated condition-n is True. 
elsestatements Optional. One or more statements executed if no previous condition or condition-n 
expression is True. 



Remarks

You can use the single-line form (first syntax) for short, simple tests. However, the block form (second 
syntax) provides more structure and flexibility than the single-line form and is usually easier to read, 
maintain, and debug.

Note   With the single-line form, it is possible to have multiple statements executed as the result of an 
If...Then decision. All statements must be on the same line and separated by colons, as in the following 
statement:

If A > 10 Then A = A + 1 : B = B + A : C = C + B

A block form If statement must be the first statement on a line. The Else, ElseIf, and End If parts of the 
statement can have only a line number or line label preceding them. The block If must end with an End 
If statement.

To determine whether or not a statement is a block If, examine what follows the Then keyword. If 
anything other than a comment appears after Then on the same line, the statement is treated as a 
single-line If statement.

The Else and ElseIf clauses are both optional. You can have as many ElseIf clauses as you want in a 
block If, but none can appear after an Else clause. Block If statements can be nested; that is, 
contained within one another.

When executing a block If (second syntax), condition is tested. If condition is True, the statements 
following Then are executed. If condition is False, each ElseIf condition (if any) is evaluated in turn. 
When a True condition is found, the statements immediately following the associated Then are 
executed. If none of the ElseIf conditions are True (or if there are no ElseIf clauses), the statements 
following Else are executed. After executing the statements following Then or Else, execution continues 
with the statement following End If.

Tip   Select Case may be more useful when evaluating a single expression that has several possible 
actions. However, the TypeOf objectname Is objecttype clause can't be used with the Select Case 
statement.

Note   TypeOf cannot be used with hard data types such as Long, Integer, and so forth other than 
Object.
scoritt
Дата: 25.11.2006 20:54:19
Не только не понял, что значит "подробная инфа по оператору if" )))))
Victosha
Дата: 25.11.2006 21:26:04
автор
However, the TypeOf objectname Is objecttype clause can't be used with the Select Case
statement.


бред.


(с выражением лица)
gregi
Дата: 25.11.2006 21:45:18
Спасибо mds_world, теперь подскажите где можно найти инфу по быстрому изучению аглицкого...
желательно с примерами
Владимир Саныч
Дата: 25.11.2006 21:48:20
Victosha
автор
However, the TypeOf objectname Is objecttype clause can't be used with the Select Case
statement.

бред.

Можешь привести пример?
mds_world
Дата: 25.11.2006 21:52:29
gregi
Спасибо mds_world, теперь подскажите где можно найти инфу по быстрому изучению аглицкого...
желательно с примерами
Ну, уж извините. Здесь другой форум.
А русский хелп есть только к аксу 97. Но IF с тех пор дополнился.
бабай
Дата: 25.11.2006 21:54:51
Владимир Саныч
...Можешь привести пример?


могу. ты и сам можешь его привести.
там водить нечего.
  Dim cc As Class1
  Set cc = New Class1
  
  Select Case True 
    Case TypeOf cc Is Form
        Debug.Print "TypeOf cc Is Class1"
    Case TypeOf cc Is Class1
        Debug.Print "TypeOf cc Is Class1"
  End Select
  
  Select Case (TypeOf cc Is Form)
    Case True
        Debug.Print "TypeOf cc Is fORM"
    Case False
        Debug.Print "TypeOf cc Is noT fORM"
  End Select
Владимир Саныч
Дата: 25.11.2006 22:23:26
Там имелось в виду другое. Невозможно сделать что-то типа:

select case typeof xxx
case is form: ...
case is control: ...
end select

А можно только так, как ты написал, т.е. либо повторять xxx в каждой строке (и вычислять его каждый раз), либо вообще отказаться от ветвления. В обоих случаях это не дает никаких преимуществ для "evaluating a single expression that has several possible actions".
бабай
Дата: 25.11.2006 23:00:52
автор
Там имелось в виду другое

я тоже считаю, что литературный текст живет только в голове читателя.
важно перепутывать последовательность событий, недоговаривать детали, перемешивать темы.

тогда текст и его герой будут оживать фантазией читателя.
вероятно ошибка - относиться к технической документации иначе.

отдельная тема - читатель должен быть подготовлен к восприятию информации.
Иначе он ее не опознает или воспримет неадекватно.

PS

Д. Хармс. 13 апреля 1933 года


Четыре иллюстрации того,
как новая идея огорашивает человека,
к ней не подготовленного



I
Писатель: Я писатель.
Читатель: А по-моему, ты го..но!


Писатель стоит несколько минут потрясенный
этой новой идеей и падает замертво. Его выносят.


II
Художник: Я художник
Рабочий: А по-моему, ты г..о!

Художник тут же побледнел как полотно,
И как тростинка закачался,
И неожиданно скончался.
Его выносят.


III

Композитор: Я композитор.
Ваня Рублев: А по-моему, ты .....!

Композитор, тяжело дыша, так и осел.
Его неожиданно выносят.


IV

Химик: Я химик.
Физик: А по моему, ты ....!

Химик не сказал больше ни слова и тяжело рухнул на пол.