本文介绍了调试时,售出的汽车数量不正确.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Option Explicit On
Option Infer On
Option Strict Off
Public Class main
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Static cars1 As Integer
Static cars2 As Integer
Static cars3 As Integer
Static cars4 As Integer
Dim txtID As String
Dim txtNumberSold As Integer
txtID = ID.Text
txtNumberSold = convertintx(NumberSold.Text)
If txtID.Substring(0, 1) = "F" Or txtID.Substring(0, 1) = "f" Then
cars1 = cars1 + txtNumberSold
Button1.Text = cars1
End If
If txtID.Substring(0, 1) = "P" Or txtID.Substring(0, 1) = "p" Then
cars2 = cars2 + txtNumberSold
Button2.Text = cars2
End If
If txtID.Substring(3, 1) = "1" Then
cars3 = cars3 + txtNumberSold
Button3.Text = cars3
End If
If txtID.Substring(3, 1) = "2" Then
cars4 = cars4 + txtNumberSold
Button4.Text = cars4
End If
ID.Text = ""
NumberSold.Text = ""
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Text = "0"
Button2.Text = "0"
Button3.Text = "0"
Button4.Text = "0"
End Sub
Private Function convertintx(ByVal strx As String)
If strx = "" Then
strx = "0"
End If
Dim s As String
s = strx
Dim str(10) As String
Dim number(10) As Integer
Dim sum As Integer
sum = 0
str = Split(s, "+")
Dim i As Integer
For i = 0 To str.Length - 1
number(i) = CInt(str(i))
sum += number(i)
Next
Return sum
End Function
推荐答案
这篇关于调试时,售出的汽车数量不正确.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!