新しいプロジェクトを作成し、別のプロジェクトから form1.vb と form1.desinger.vb を新しいプロジェクトに追加しました (別のコンピューターで作業していて、2 つのソースを USB に保存し、自宅のコンピューターに移動して、2 つのソースを追加するだけでよいと考えました)。私のUSBからプロジェクトへのファイルとそれはうまくいくでしょう.) 今私のデザインビューはボタンやラベルを表示していません; しかし、コードはまだそこにあり、プログラムを実行しても機能します(すべてのコントロールを含むフォームを見ることができます)。デザイン ビューを使用してコントロールのプロパティを更新することはできません。ボタンとラベルをデザイン ビューに戻して編集できるようにしたいと考えています。ここに form1.designer.vb コードがあります:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.txtAdultSold = New System.Windows.Forms.TextBox()
Me.txtAdultPrice = New System.Windows.Forms.TextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label1 = New System.Windows.Forms.Label()
Me.GroupBox2 = New System.Windows.Forms.GroupBox()
Me.txtChildSold = New System.Windows.Forms.TextBox()
Me.txtChildPrice = New System.Windows.Forms.TextBox()
Me.Label4 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.GroupBox3 = New System.Windows.Forms.GroupBox()
Me.txtTotalGross = New System.Windows.Forms.TextBox()
Me.txtChildSalesGross = New System.Windows.Forms.TextBox()
Me.txtAdultSalesGross = New System.Windows.Forms.TextBox()
Me.Label7 = New System.Windows.Forms.Label()
Me.Label6 = New System.Windows.Forms.Label()
Me.Label5 = New System.Windows.Forms.Label()
Me.GroupBox4 = New System.Windows.Forms.GroupBox()
Me.txtTotalNet = New System.Windows.Forms.TextBox()
Me.txtChildSalesNet = New System.Windows.Forms.TextBox()
Me.txtAdultSalesNet = New System.Windows.Forms.TextBox()
Me.Label10 = New System.Windows.Forms.Label()
Me.Label9 = New System.Windows.Forms.Label()
Me.Label8 = New System.Windows.Forms.Label()
Me.btnCalucateTicketRev = New System.Windows.Forms.Button()
Me.btnClear = New System.Windows.Forms.Button()
Me.btnExit = New System.Windows.Forms.Button()
Me.GroupBox1.SuspendLayout()
Me.GroupBox2.SuspendLayout()
Me.GroupBox3.SuspendLayout()
Me.GroupBox4.SuspendLayout()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.AutoSize = True
Me.GroupBox1.Controls.Add(Me.txtAdultSold)
Me.GroupBox1.Controls.Add(Me.txtAdultPrice)
Me.GroupBox1.Controls.Add(Me.Label2)
Me.GroupBox1.Controls.Add(Me.Label1)
Me.GroupBox1.ForeColor = System.Drawing.SystemColors.HotTrack
Me.GroupBox1.Location = New System.Drawing.Point(22, 22)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(236, 122)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Adult Ticket Sales"
'
'txtAdultSold
'
Me.txtAdultSold.Location = New System.Drawing.Point(114, 59)
Me.txtAdultSold.Name = "txtAdultSold"
Me.txtAdultSold.Size = New System.Drawing.Size(100, 20)
Me.txtAdultSold.TabIndex = 2
'
'txtAdultPrice
'
Me.txtAdultPrice.Location = New System.Drawing.Point(114, 27)
Me.txtAdultPrice.Name = "txtAdultPrice"
Me.txtAdultPrice.Size = New System.Drawing.Size(100, 20)
Me.txtAdultPrice.TabIndex = 1
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label2.Location = New System.Drawing.Point(38, 59)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(69, 13)
Me.Label2.TabIndex = 1
Me.Label2.Text = "Tickets Sold:"
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label1.Location = New System.Drawing.Point(22, 27)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(85, 13)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Price per Ticket:"
'
'GroupBox2
'
Me.GroupBox2.AutoSize = True
Me.GroupBox2.Controls.Add(Me.txtChildSold)
Me.GroupBox2.Controls.Add(Me.txtChildPrice)
Me.GroupBox2.Controls.Add(Me.Label4)
Me.GroupBox2.Controls.Add(Me.Label3)
Me.GroupBox2.ForeColor = System.Drawing.SystemColors.HotTrack
Me.GroupBox2.Location = New System.Drawing.Point(274, 22)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(234, 122)
Me.GroupBox2.TabIndex = 1
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "Child Ticket Sales"
'
'txtChildSold
'
Me.txtChildSold.Location = New System.Drawing.Point(108, 51)
Me.txtChildSold.Name = "txtChildSold"
Me.txtChildSold.Size = New System.Drawing.Size(100, 20)
Me.txtChildSold.TabIndex = 4
'
'txtChildPrice
'
Me.txtChildPrice.Location = New System.Drawing.Point(108, 20)
Me.txtChildPrice.Name = "txtChildPrice"
Me.txtChildPrice.Size = New System.Drawing.Size(100, 20)
Me.txtChildPrice.TabIndex = 3
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label4.Location = New System.Drawing.Point(31, 58)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(69, 13)
Me.Label4.TabIndex = 1
Me.Label4.Text = "Tickets Sold:"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label3.Location = New System.Drawing.Point(15, 20)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(85, 13)
Me.Label3.TabIndex = 0
Me.Label3.Text = "Price per Ticket:"
'
'GroupBox3
'
Me.GroupBox3.AutoSize = True
Me.GroupBox3.Controls.Add(Me.txtTotalGross)
Me.GroupBox3.Controls.Add(Me.txtChildSalesGross)
Me.GroupBox3.Controls.Add(Me.txtAdultSalesGross)
Me.GroupBox3.Controls.Add(Me.Label7)
Me.GroupBox3.Controls.Add(Me.Label6)
Me.GroupBox3.Controls.Add(Me.Label5)
Me.GroupBox3.ForeColor = System.Drawing.SystemColors.HotTrack
Me.GroupBox3.Location = New System.Drawing.Point(22, 150)
Me.GroupBox3.Name = "GroupBox3"
Me.GroupBox3.Size = New System.Drawing.Size(236, 152)
Me.GroupBox3.TabIndex = 2
Me.GroupBox3.TabStop = False
Me.GroupBox3.Text = "Gross Ticket Revenue"
'
'txtTotalGross
'
Me.txtTotalGross.Location = New System.Drawing.Point(120, 99)
Me.txtTotalGross.Name = "txtTotalGross"
Me.txtTotalGross.ReadOnly = True
Me.txtTotalGross.Size = New System.Drawing.Size(100, 20)
Me.txtTotalGross.TabIndex = 5
'
'txtChildSalesGross
'
Me.txtChildSalesGross.Location = New System.Drawing.Point(117, 59)
Me.txtChildSalesGross.Name = "txtChildSalesGross"
Me.txtChildSalesGross.ReadOnly = True
Me.txtChildSalesGross.Size = New System.Drawing.Size(100, 20)
Me.txtChildSalesGross.TabIndex = 4
'
'txtAdultSalesGross
'
Me.txtAdultSalesGross.Location = New System.Drawing.Point(117, 21)
Me.txtAdultSalesGross.Name = "txtAdultSalesGross"
Me.txtAdultSalesGross.ReadOnly = True
Me.txtAdultSalesGross.Size = New System.Drawing.Size(100, 20)
Me.txtAdultSalesGross.TabIndex = 3
'
'Label7
'
Me.Label7.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label7.ImageAlign = System.Drawing.ContentAlignment.TopLeft
Me.Label7.Location = New System.Drawing.Point(6, 98)
Me.Label7.Name = "Label7"
Me.Label7.RightToLeft = System.Windows.Forms.RightToLeft.Yes
Me.Label7.Size = New System.Drawing.Size(110, 38)
Me.Label7.TabIndex = 2
Me.Label7.Text = "Total Gross Revenue :for Ticket Sales"
'
'Label6
'
Me.Label6.AutoSize = True
Me.Label6.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label6.Location = New System.Drawing.Point(19, 59)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(95, 13)
Me.Label6.TabIndex = 1
Me.Label6.Text = "Child Ticket Sales:"
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label5.Location = New System.Drawing.Point(16, 20)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(96, 13)
Me.Label5.TabIndex = 0
Me.Label5.Text = "Adult Ticket Sales:"
'
'GroupBox4
'
Me.GroupBox4.AutoSize = True
Me.GroupBox4.Controls.Add(Me.txtTotalNet)
Me.GroupBox4.Controls.Add(Me.txtChildSalesNet)
Me.GroupBox4.Controls.Add(Me.txtAdultSalesNet)
Me.GroupBox4.Controls.Add(Me.Label10)
Me.GroupBox4.Controls.Add(Me.Label9)
Me.GroupBox4.Controls.Add(Me.Label8)
Me.GroupBox4.ForeColor = System.Drawing.SystemColors.HotTrack
Me.GroupBox4.Location = New System.Drawing.Point(274, 150)
Me.GroupBox4.Name = "GroupBox4"
Me.GroupBox4.Size = New System.Drawing.Size(234, 137)
Me.GroupBox4.TabIndex = 3
Me.GroupBox4.TabStop = False
Me.GroupBox4.Text = "Net Ticket Revenue"
'
'txtTotalNet
'
Me.txtTotalNet.Location = New System.Drawing.Point(123, 91)
Me.txtTotalNet.Name = "txtTotalNet"
Me.txtTotalNet.ReadOnly = True
Me.txtTotalNet.Size = New System.Drawing.Size(100, 20)
Me.txtTotalNet.TabIndex = 5
'
'txtChildSalesNet
'
Me.txtChildSalesNet.Location = New System.Drawing.Point(123, 59)
Me.txtChildSalesNet.Name = "txtChildSalesNet"
Me.txtChildSalesNet.ReadOnly = True
Me.txtChildSalesNet.Size = New System.Drawing.Size(100, 20)
Me.txtChildSalesNet.TabIndex = 4
'
'txtAdultSalesNet
'
Me.txtAdultSalesNet.Location = New System.Drawing.Point(123, 19)
Me.txtAdultSalesNet.Name = "txtAdultSalesNet"
Me.txtAdultSalesNet.ReadOnly = True
Me.txtAdultSalesNet.Size = New System.Drawing.Size(100, 20)
Me.txtAdultSalesNet.TabIndex = 3
'
'Label10
'
Me.Label10.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label10.Location = New System.Drawing.Point(6, 91)
Me.Label10.Name = "Label10"
Me.Label10.RightToLeft = System.Windows.Forms.RightToLeft.Yes
Me.Label10.Size = New System.Drawing.Size(110, 28)
Me.Label10.TabIndex = 2
Me.Label10.Text = "Total Net Revenue :for Ticket Sales"
'
'Label9
'
Me.Label9.AutoSize = True
Me.Label9.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label9.Location = New System.Drawing.Point(21, 59)
Me.Label9.Name = "Label9"
Me.Label9.Size = New System.Drawing.Size(95, 13)
Me.Label9.TabIndex = 1
Me.Label9.Text = "Child Ticket Sales:"
'
'Label8
'
Me.Label8.AutoSize = True
Me.Label8.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label8.Location = New System.Drawing.Point(21, 19)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(96, 13)
Me.Label8.TabIndex = 0
Me.Label8.Text = "Adult Ticket Sales:"
'
'btnCalucateTicketRev
'
Me.btnCalucateTicketRev.BackColor = System.Drawing.SystemColors.Window
Me.btnCalucateTicketRev.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnCalucateTicketRev.Location = New System.Drawing.Point(133, 315)
Me.btnCalucateTicketRev.Name = "btnCalucateTicketRev"
Me.btnCalucateTicketRev.Size = New System.Drawing.Size(96, 50)
Me.btnCalucateTicketRev.TabIndex = 4
Me.btnCalucateTicketRev.Text = "&Calculate Ticket Revenue"
Me.btnCalucateTicketRev.UseVisualStyleBackColor = False
'
'btnClear
'
Me.btnClear.Location = New System.Drawing.Point(235, 315)
Me.btnClear.Name = "btnClear"
Me.btnClear.Size = New System.Drawing.Size(74, 50)
Me.btnClear.TabIndex = 5
Me.btnClear.Text = "Cl&ear"
Me.btnClear.UseVisualStyleBackColor = True
'
'btnExit
'
Me.btnExit.Location = New System.Drawing.Point(316, 315)
Me.btnExit.Name = "btnExit"
Me.btnExit.Size = New System.Drawing.Size(74, 50)
Me.btnExit.TabIndex = 6
Me.btnExit.Text = "E&xit"
Me.btnExit.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(520, 430)
Me.Controls.Add(Me.btnExit)
Me.Controls.Add(Me.btnClear)
Me.Controls.Add(Me.btnCalucateTicketRev)
Me.Controls.Add(Me.GroupBox4)
Me.Controls.Add(Me.GroupBox3)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.GroupBox1)
Me.Name = "Form1"
Me.Text = "Theater Revenue"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox1.PerformLayout()
Me.GroupBox2.ResumeLayout(False)
Me.GroupBox2.PerformLayout()
Me.GroupBox3.ResumeLayout(False)
Me.GroupBox3.PerformLayout()
Me.GroupBox4.ResumeLayout(False)
Me.GroupBox4.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
Friend WithEvents GroupBox4 As System.Windows.Forms.GroupBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label10 As System.Windows.Forms.Label
Friend WithEvents Label9 As System.Windows.Forms.Label
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents txtAdultSold As System.Windows.Forms.TextBox
Friend WithEvents txtAdultPrice As System.Windows.Forms.TextBox
Friend WithEvents txtChildSold As System.Windows.Forms.TextBox
Friend WithEvents txtChildPrice As System.Windows.Forms.TextBox
Friend WithEvents txtTotalGross As System.Windows.Forms.TextBox
Friend WithEvents txtChildSalesGross As System.Windows.Forms.TextBox
Friend WithEvents txtAdultSalesGross As System.Windows.Forms.TextBox
Friend WithEvents txtTotalNet As System.Windows.Forms.TextBox
Friend WithEvents txtChildSalesNet As System.Windows.Forms.TextBox
Friend WithEvents txtAdultSalesNet As System.Windows.Forms.TextBox
Friend WithEvents btnCalucateTicketRev As System.Windows.Forms.Button
Friend WithEvents btnClear As System.Windows.Forms.Button
Friend WithEvents btnExit As System.Windows.Forms.Button
クラス終了
form1.vb コード:
Public Class Form1
Dim tickets_Sold_Adult As Integer
Dim ticktes_Sold_Child As Integer
Dim price_Adult As Double
Dim price_Child As Double
Dim totalAdult, totalChild, pretotal As Double
Const profitNet As Double = 0.2
Private Sub txtAdultPrice_TextChanged(sender As Object, e As EventArgs) Handles txtAdultPrice.TextChanged
If IsNumeric(txtAdultPrice.Text) Then
price_Adult = txtAdultPrice.Text
End If
End Sub
Private Sub txtAdultSold_TextChanged(sender As Object, e As EventArgs) Handles txtAdultSold.TextChanged
If IsNumeric(txtAdultSold.Text) Then
tickets_Sold_Adult = txtAdultSold.Text
End If
End Sub
Private Sub txtChildPrice_TextChanged(sender As Object, e As EventArgs) Handles txtChildPrice.TextChanged
If IsNumeric(txtChildPrice.Text) Then
price_Child = txtChildPrice.Text
End If
End Sub
Private Sub txtChildSold_TextChanged(sender As Object, e As EventArgs) Handles txtChildSold.TextChanged
If IsNumeric(txtChildSold.Text) Then
ticktes_Sold_Child = txtChildSold.Text
End If
End Sub
Private Sub btnCalucateTicketRev_Click(sender As Object, e As EventArgs) Handles btnCalucateTicketRev.Click
totalAdult = price_Adult * tickets_Sold_Adult
txtAdultSalesGross.Text = Format(totalAdult, "$0.00")
txtAdultSalesNet.Text = Format(totalAdult * 0.2, "$0.00")
totalChild = price_Child * ticktes_Sold_Child
txtChildSalesGross.Text = Format(totalChild, "$0.00")
txtChildSalesNet.Text = Format(totalChild * 0.2, "$0.00")
pretotal = (totalAdult + totalChild)
txtTotalGross.Text = Format(pretotal, "$0.00")
txtTotalNet.Text = Format(profitNet * pretotal, "$0.00")
End Sub
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
txtAdultPrice.Clear()
txtAdultSold.Clear()
txtChildPrice.Clear()
txtChildSold.Clear()
txtAdultSalesGross.Clear()
txtAdultSalesNet.Clear()
txtChildSalesGross.Clear()
txtChildSalesNet.Clear()
txtTotalGross.Clear()
txtTotalNet.Clear()
price_Adult = 0
price_Child = 0
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
クラス終了