VB6中的控制数组计算器

时间:2018-06-11 12:09:32

标签: arrays vb6

在我的计算类中,我们一直在使用控制数组来创建基本计算器。请记住,我之前从未使用过控制数组。 这是我目前的代码:

  var zoom1, zoom2, zoom3;
queue()
  .defer(d3.json, 'zm1.json')
  .defer(d3.json, 'zm2.json')
  .defer(d3.json, 'zm3.json')
  .await(buildMap);

function buildMap(error, zoom1Data, zoom2Data, zoom3Data) {
  if (error) throw error;
  console.log('', bigData, smallData);
  zoom1 = zoom1Data;
  zoom2 = zoom2Data;
  drawMap(zoom2)
}

function drawMap(data) {

  g.selectAll("path")
    .data(data.features)
    .enter().append("path")
    .attr("d", path)
    .attr("class", " feature")
    .attr("stroke", "white")
    .attr("stroke-width", 1)
    .on("click", clicked)

  g.append("path")
    .datum(data.features)
    .attr("class", "mesh")
    .attr("d", path);
}

function clicked(d) {
  if (active.node() === this) return reset();
  active.classed("active", false);
  active = d3.select(this).classed("active", true);

  var bounds = path.bounds(d),
    dx = bounds[1][0] - bounds[0][0],
    dy = bounds[1][1] - bounds[0][1],
    x = (bounds[0][0] + bounds[1][0]) / 2,
    y = (bounds[0][1] + bounds[1][1]) / 2,
    scale = .9 / Math.max(dx / width, dy / height),
    translate = [width / 2 - scale * x, height / 2 - scale * y];

  g.transition()
    .duration(750)
    .style("stroke-width", 1.5 / scale + "px")
    .attr("transform", "translate(" + translate + ")scale(" + scale + ")")
    .each("end", function(){
      console.log('',"END");
      drawMap(zoom2)           <- Draw next level 
    })
}

function reset() {
  active.classed("active", false);
  active = d3.select(null);
  g.transition()
    .duration(750)
    .style("stroke-width", "1.5px")
    .attr("transform", "");
}

我似乎唯一的问题是,按下&#34; =&#34;按钮TempSave2变量(用于得到我的答案)是空白而不是用户输入的数字。我不确定如何解决这个问题我尝试重新排列这一切。任何帮助表示赞赏。

首先发帖在这里请原谅糟糕的布局!

谢谢,Keiran。

enter image description here

请原谅糟糕的配色方案。我的想法是,如果我的老师让我学习这个可怕的概念,他可以应对可怕的颜色:P

1 个答案:

答案 0 :(得分:3)

首先,您要检查下面的索引值,而不是CmdCalc(索引):

If Index = 10 Then
    TempSave1 = LblOutput.Caption
    Symbol = "/"
ElseIf Index = 11 Then
    TempSave1 = LblOutput.Caption
    Symbol = "*"
ElseIf Index = 12 Then
    TempSave1 = LblOutput.Caption
    Symbol = "-"
ElseIf Index = 14 Then
    TempSave1 = LblOutput.Caption
    Symbol = "+"
End If

接下来,你的行:

If Index = 0 Or 1 Or 2 Or 3 Or 4 Or 5 Or 6 Or 7 Or 8 Or 9 Or 10 Or 11 Or 12 Or 14 Then

没有做你认为它正在做的事情。它正在一起评估所有Or语句,然后将其与Index进行比较。就好像是用下面的括号写的:

If Index = (0 Or 1 Or 2 Or 3 Or 4 Or 5 Or 6 Or 7 Or 8 Or 9 Or 10 Or 11 Or 12 Or 14) Then

我相信如果Index = 14,代码只会评估为true,但我没有完成实际的数学运算,但无论如何,它显然不是你想要的。

有几种方法可以写这个,但最短的可能是:

If (Index >= 0 And Index <= 12) Or Index = 14 Then

在没有看到实际屏幕的情况下,我无法对其余代码发表评论。

相关问题