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
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)