我正在尝试使用复选框1填充短语“缺席”#39;勾选复选框时在下一个空行中,当在命令按钮中将用户表单提交到电子表格时,在列O中。
以下代码适用于我提交的#39;命令按钮,没有任何问题。我如何合并复选框,将“缺席' 添加到与当前添加的其他信息完全相同的行?
此外,我希望该复选框能够在提交表单时恢复到未经检查的状态。
非常感谢任何帮助。
命令按钮提交代码为:
String selectStr = "select * from emp";
ResultSet rs = ps.executeQuery ();
while(rs.next())
{
.....
}
将数据保存到电子表格:
Private Sub CommandButton1_Click()
Set ThisRow = Range("A" & Rows.Count).End(xlUp)
If ThisRow.Row = 1 Then
Me.TextBox1 = 1
Else
Me.TextBox1 = ThisRow.Row + 1
End If
Me.TextBox2.Value = Now
Set ThisRow = ThisRow.Offset(1)
SaveData
End Sub
初始化代码为:
Private Sub SaveData()
Dim C As MSForms.Control
Dim varValue As Variant 'Must be variant to accept different types of data
For Each C In Me.Controls
If C.Tag <> "" Then
varValue = C.Value
Select Case C.Tag
Case "A", "D", "H", "I", "J", "K", "L", "M", "N", "O"
Worksheets("Data").Range(C.Tag & ThisRow.Row) = varValue
Case "B", "C", "E"
If IsDate(varValue) Then
Worksheets("Data").Range(C.Tag & ThisRow.Row) = CDate(varValue)
End If
End Select
等等等等
答案 0 :(得分:0)
将以下内容添加到savedata
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: sans-serif;
}
#controlPanel {
float: left;
padding-top: 30px;
}
.button {
background-color: gray;
color: white;
border-radius: 10px;
padding: 20px;
text-align: center;
margin: 90px 40px;
cursor: pointer;
}
#traffic-light {
width: 150px;
float: left;
background-color: #333;
border-radius: 40px;
margin: 30px 0;
padding: 20px;
}
.bulb {
height: 100px;
width: 100px;
background-color: #111;
border-radius: 50%;
margin: 25px auto;
transition: background 500ms;
}
#controlPanel>h1 {
margin-top: 15px;
margin-bottom: 15px;
}
</style>
<script src="/scripts/snippet-javascript-console.min.js?v=1"></script>
</head>
<body>
<div id="controlPanel">
<h1 id="stopButton" class="button">Stop</h1>
<h1 id="slowButton" class="button">Slow</h1>
<h1 id="goButton" class="button">Go</h1>
<h1 id="Lights" class="button">Clear</h1>
<h1 id="autoLights" class="button">Auto</h1>
</div>
<div id="traffic-light">
<div id="stopLight" class="bulb"></div>
<div id="slowLight" class="bulb"></div>
<div id="goLight" class="bulb"></div>
</div>
<script type="text/javascript">
document.getElementById('stopButton').onclick = stopRed;
document.getElementById('slowButton').onclick = slowYellow;
document.getElementById('goButton').onclick = goGreen;
document.getElementById('Lights').onclick = Lights;
document.getElementById('autoLights').onclick = autoLights;
function stopRed() {
Lights();
document.getElementById('stopLight').style.backgroundColor = "red";
}
function slowYellow() {
Lights();
document.getElementById('slowLight').style.backgroundColor = "orange";
}
function goGreen() {
Lights();
document.getElementById('goLight').style.backgroundColor = "green";
}
function Lights() {
document.getElementById('stopLight').style.backgroundColor = "black";
document.getElementById('slowLight').style.backgroundColor = "black";
document.getElementById('goLight').style.backgroundColor = "black";
}
function lightOne(num) {
Lights();
switch (num) {
case 1:
stopRed();
break;
case 2:
slowYellow();
break;
case 3:
goGreen();
break;
default:
alert("you made some error");
}
}
counter = 0;
maxSec = 3;
function timer() {
setTimeout(function() {
counter++;
lightOne(counter);
if (counter == maxSec) {
return;
}
timer();
}, 2000);
}
function autoLights() {
counter = 1;
lightOne(counter);
timer();
}
</script>
</body>
</html>
答案 1 :(得分:0)
好的,您的输入非常有用。我还需要在“初始化”下声明它,我现在已经完成了。问题解决了。