供应仓储笼:vb高手看一下这十几行源码,为什么一执行就显示:“编译错误:end select没有select case”

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/28 03:50:10
Dim Num1, Num2 As Single
Dim StrNum1, StrNum2 As String
Dim FirstNum As Boolean
Dim pointflag As Boolean
Sub ClearData()
Num1 = 0
Num2 = 0
StrNum1 = ""
StrNum2 = ""
FirstNum = True
pointflag = False
End Sub
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0 To 9
If FirstNum Then
StrNum1 = Str(Index)
FirstNum = False
Else
StrNum1 = StrNum1 + Str(Index)
End If
Case 10
If pointflag = False Then
If StrNum1 = True Then
StrNum1 = "0."
StrNum1 = False
Else
StrNum1 = StrNum1 + "."
pointflag = True
End If
If pointflag = True Then
Exit Sub
End If
Text1.Text = StrNum1
End Select
End Sub

Private Sub Form_Load()

End Sub

为什么一执行就显示:“编译错误:end select没有select case”
可我已写了个end select和select case,请说清楚点

少个end if

在end sub 上面加一个end if就行了

可以看出你的语句少一个end if
StrNum1 = False(与你定义的类型不一样了!!)

Case 10
If pointflag = False Then
If StrNum1 = True Then
StrNum1 = "0."
StrNum1 = False
Else
StrNum1 = StrNum1 + "."
pointflag = True
End If
If pointflag = True Then
Exit Sub
End If
Text1.Text = StrNum1
后加一个“ end if”
反正是第一个if语句没有结束语句。

大家都说对了!

后面又少个 end if ,另外你的代码写的不规范例,不太好看,以后这样写程序,把我这块复制过去就好用了!
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0 To 9
If FirstNum Then
StrNum1 = Str(Index)
FirstNum = False
Else
StrNum1 = StrNum1 + Str(Index)
End If
Case 10
If pointflag = False Then
If StrNum1 = True Then
StrNum1 = "0."
StrNum1 = False
Else
StrNum1 = StrNum1 + "."
pointflag = True
End If
If pointflag = True Then Exit Sub '这可以这样写,你写的少个end if ,也可以像我这样写
End If
Text1.Text = StrNum1
End Select
End Sub