如果语句循环 - 否则,否则如果

时间:2015-08-05 11:24:49

标签: vba loops if-statement

我想知道是否有人可以帮助解决以下简单的代码:

PROJECT(project_name)

SET(SRC_FILES xxx.c xxx.c xxx.c xxx.c)

FIND_PACKAGE(SDL2 REQUIRED)
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR})

FIND_PACKAGE(OPENGL REQUIRED)
INCLUDE_DIRECTORIES( ${OPENGL_INCLUDE_DIR})

FIND_PACKAGE(SDL_IMAGE REQUIRED)
INCLUDE_DIRECTORIES( ${SDL2_IMAGE_INCLUDE_DIR})

ADD_LIBRARY(project_name SHARED ${SRC_FILES})
TARGET_LINK_LIBRARIES(project_name ${SDL2_LIBRARY} ${OPENGL_LIBRARIES} ${SDL2_IMAGE_LIBRARY})

我基本上试图复制if语句,根据IF语句的真实与否,给出3种不同的结果。

2 个答案:

答案 0 :(得分:2)

试试这个;

<html>
<head>
<title>Exam entry</title>
<script language="javascript" type="text/javascript">
var number = true;
var validNumbers = "0123456789";
var character;
function validateForm() {
var result = true;
var msg="";

if (document.ExamEntry.name.value=="") {
msg+="You must enter your name \n";
document.ExamEntry.name.focus();
document.getElementById('name').style.color="red";
result = false;
}
if (document.ExamEntry.subject.value=="") {
msg+="You must enter the subject \n";
document.ExamEntry.subject.focus();
document.getElementById('subject').style.color="red";
result = false;
}
number = true
for(var i = 0;i<document.ExamEntry.examNumber.value.length;i++){
character = document.ExamEntry.examNumber.value.charAt(i); 
if (validNumbers.indexOf(character) == -1){
number = false;
}
}
if (document.ExamEntry.examNumber.value.length != 4||number==false){
msg+="You must enter your examination number correctly \n";
document.ExamEntry.examNumber.focus();
document.getElementById('examNumber').style.color="red";
result = false;
}
if(msg==""){
return result;
}
{
alert(msg)
return result;
}
}
</script>
</head>
<body>
<h1>Exam Entry Form</h1>
<form name="ExamEntry" method="post" action="success.html">
<table width="50%" border="0">
<tr>
<td id="name">Name</td>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<td id="subject">Subject</td>
<td><input type="text" name="subject" /></td>
</tr>
<tr>
<td id="examNumber">Examination Number</td>
<td><input type="text" name="examNumber" /></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Submit" onclick="return validateForm();" /></td>
<td><input type="reset" name="Reset" value="Reset" /></td>
</tr>
</table>
</form>
</body>
</html>

答案 1 :(得分:1)

如果您不了解有关命令语法的在线帮助,您应该熟悉它。

例如,如果here

一般here

For Each cell In Range(Cells(2, 5), Cells(lastrow1, 5))

    If cell.Offset(, -3) = cell.Offset(1, -3) Then
            cell.Value = cell.Offset(, -1)

    ElseIf cell.Offset(, -3) = cell.Offset(-1, -3) Then

        cell.Value = 0

    Else

        cell.Value = cell.Offset(, -1)

    End If
Next