if edit1.Text:='' then end; end if 以上是符合Object pascal语法的代码吗? then后面是条可执行命令,不是一个控制结构 还有end if 不伦不类的代码,是VB的吗?
if edit1.Text:='' then end; end if 错误很多,看来不太熟悉OP语法啊,if edit1.Text='' then close;
呵呵,楼主用什么语言啊? 怎么看,也不像DELPHI,不出错才怪呢!
if edit1.Text:='' then //:是做什么,比较不能用,用了就是赋值操作 end;//和什么对应?单个的end是不能使用的 end if //为什么又有个end 晕,你还是看看 if语句是怎么用得吧 There are two forms of if statement: if...then and the if...then...else. The syntax of an if...then statement isif expression then statementwhere expression returns a Boolean value. If expression is True, then statement is executed; otherwise it is not. For example,if J <> 0 then Result := I/J;The syntax of an if...then...else statement isif expression then statement1 else statement2where expression returns a Boolean value. If expression is True, then statement1 is executed; otherwise statement2 is executed. For example,if J = 0 then Exit else Result := I/J;The then and else clauses contain one statement each, but it can be a structured statement. For example,if J <> 0 then begin Result := I/J; Count := Count + 1; end else if Count = Last then Done := True else Exit;Notice that there is never a semicolon between the then clause and the word else. You can place a semicolon after an entire if statement to separate it from the next statement in its block, but the then and else clauses require nothing more than a space or carriage return between them. Placing a semicolon immediately before else (in an if statement) is a common programming error.A special difficulty arises in connection with nested if statements. The problem arises because some if statements have else clauses while others do not, but the syntax for the two kinds of statement is otherwise the same. In a series of nested conditionals where there are fewer else clauses than if statements, it may not seem clear which else clauses are bound to which ifs. Consider a statement of the formif expression1 then if expression2 then statement1 else statement2;There would appear to be two ways to parse this:if expression1 then [ if expression2 then statement1 else statement2]; if expression1 then [ if expression2 then statement1] else statement2;The compiler always parses in the first way. That is, in real code, the statementif ... { expression1 } then if ... { expression2 } then ... { statement1 } else ... { statement2 } ;is equivalent toif ... { expression1 } then begin if ... { expression2 } then ... { statement1 } else ... { statement2 } end;The rule is that nested conditionals are parsed starting from the innermost conditional, with each else bound to the nearest available if on its left. To force the compiler to read our example in the second way, you would have to write it explicitly asif ... { expression1 } then begin if ... { expression2 } then ... { statement1 } end else ... { statement2 } ;
if edit.text='' then begin end;没有:号呀,那赋值语句.
if trim(edit.text)='' then begin showmessage('haha!'); end;
if edit1.Text:='' then begin ShowMessage('错误,请输入内容.'); edit1.SetFocus(); Exit; end; end if
end;
end if
以上是符合Object pascal语法的代码吗?
then后面是条可执行命令,不是一个控制结构
还有end if 不伦不类的代码,是VB的吗?
end;
end if
错误很多,看来不太熟悉OP语法啊,if edit1.Text='' then
close;
怎么看,也不像DELPHI,不出错才怪呢!
end;//和什么对应?单个的end是不能使用的
end if //为什么又有个end
晕,你还是看看 if语句是怎么用得吧
There are two forms of if statement: if...then and the if...then...else. The syntax of an if...then statement isif expression then statementwhere expression returns a Boolean value. If expression is True, then statement is executed; otherwise it is not. For example,if J <> 0 then Result := I/J;The syntax of an if...then...else statement isif expression then statement1 else statement2where expression returns a Boolean value. If expression is True, then statement1 is executed; otherwise statement2 is executed. For example,if J = 0 then
Exit
else
Result := I/J;The then and else clauses contain one statement each, but it can be a structured statement. For example,if J <> 0 then
begin
Result := I/J;
Count := Count + 1;
end
else if Count = Last then
Done := True
else
Exit;Notice that there is never a semicolon between the then clause and the word else. You can place a semicolon after an entire if statement to separate it from the next statement in its block, but the then and else clauses require nothing more than a space or carriage return between them. Placing a semicolon immediately before else (in an if statement) is a common programming error.A special difficulty arises in connection with nested if statements. The problem arises because some if statements have else clauses while others do not, but the syntax for the two kinds of statement is otherwise the same. In a series of nested conditionals where there are fewer else clauses than if statements, it may not seem clear which else clauses are bound to which ifs. Consider a statement of the formif expression1 then if expression2 then statement1 else statement2;There would appear to be two ways to parse this:if expression1 then [ if expression2 then statement1 else statement2];
if expression1 then [ if expression2 then statement1] else statement2;The compiler always parses in the first way. That is, in real code, the statementif ... { expression1 } then
if ... { expression2 } then
... { statement1 }
else
... { statement2 } ;is equivalent toif ... { expression1 } then
begin
if ... { expression2 } then
... { statement1 }
else
... { statement2 }
end;The rule is that nested conditionals are parsed starting from the innermost conditional, with each else bound to the nearest available if on its left. To force the compiler to read our example in the second way, you would have to write it explicitly asif ... { expression1 } then
begin
if ... { expression2 } then
... { statement1 }
end
else
... { statement2 } ;
begin
end;没有:号呀,那赋值语句.
begin
showmessage('haha!');
end;
begin
ShowMessage('错误,请输入内容.');
edit1.SetFocus();
Exit;
end;
end if