質問編集履歴
2
誤字修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,7 +40,7 @@
|
|
40
40
|
Dim pbox As PictureBox = DirectCast(sender, PictureBox)
|
41
41
|
Using child As New Form2()
|
42
42
|
If child.ShowDialog() = DialogResult.OK Then
|
43
|
-
ListBox1.Items.Add(
|
43
|
+
ListBox1.Items.Add(pbox.Tag & child.StockCount & " ¥100")
|
44
44
|
End If
|
45
45
|
End Using
|
46
46
|
End If
|
1
windowsformアプリケーションを使用していることを明記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,8 +1,65 @@
|
|
1
1
|
visual stadio 2022 visual basicについての質問です。
|
2
|
+
windows Form アプリケーションを使用しています。
|
2
3
|
listboxにて
|
3
|
-
商品名x1 ¥100
|
4
|
+
商品名1 x1 ¥100
|
4
|
-
商品名x1 ¥200
|
5
|
+
商品名2 x1 ¥200
|
5
6
|
・
|
6
7
|
・
|
7
8
|
のようなものを表示させるプログラムを作成しました。最後に合計金額を求めたいのですが、¥より後ろの数字を抜き出して合計金額を求める方法はありますか?
|
9
|
+
```ここに言語を入力
|
10
|
+
Public Class Form1
|
11
|
+
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
12
|
+
Connectcontrols()
|
13
|
+
Connectevents()
|
14
|
+
PictureBox1.Tag = "商品名1"
|
15
|
+
PictureBox1.Image = Image.FromFile("test.bmp")
|
16
|
+
PictureBox2.Tag = "商品名2"
|
17
|
+
PictureBox2.Image = Image.FromFile("test.bmp")
|
18
|
+
PictureBox3.Tag = "商品名3"
|
19
|
+
PictureBox3.Image = Image.FromFile("test.bmp")
|
20
|
+
End Sub
|
8
21
|
|
22
|
+
Private mypicturebox() As System.Windows.Forms.PictureBox
|
23
|
+
|
24
|
+
Private Sub Connectcontrols()
|
25
|
+
mypicturebox = New System.Windows.Forms.PictureBox(3) {}
|
26
|
+
mypicturebox(1) = PictureBox1
|
27
|
+
mypicturebox(2) = PictureBox2
|
28
|
+
mypicturebox(3) = PictureBox3
|
29
|
+
End Sub
|
30
|
+
|
31
|
+
Private Sub Connectevents()
|
32
|
+
For i As Integer = 1 To 3
|
33
|
+
AddHandler mypicturebox(i).Click, AddressOf mypicturebox_Click
|
34
|
+
Next
|
35
|
+
End Sub
|
36
|
+
|
37
|
+
Private Sub Mypicturebox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
|
38
|
+
Dim index As Integer = Array.IndexOf(mypicturebox, sender)
|
39
|
+
If index = 1 Then
|
40
|
+
Dim pbox As PictureBox = DirectCast(sender, PictureBox)
|
41
|
+
Using child As New Form2()
|
42
|
+
If child.ShowDialog() = DialogResult.OK Then
|
43
|
+
ListBox1.Items.Add(String.Format("{0} x {1}", pbox.Tag, child.StockCount & " \100"))
|
44
|
+
End If
|
45
|
+
End Using
|
46
|
+
End If
|
47
|
+
以下 index=3 まで行う
|
48
|
+
|
49
|
+
Public Class Form2
|
50
|
+
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
51
|
+
_StockCount = NumericUpDown1.Value
|
52
|
+
DialogResult = DialogResult.OK
|
53
|
+
End Sub
|
54
|
+
|
55
|
+
Private _StockCount As Decimal
|
56
|
+
|
57
|
+
Public ReadOnly Property StockCount As Decimal
|
58
|
+
Get
|
59
|
+
Return _StockCount
|
60
|
+
End Get
|
61
|
+
End Property
|
62
|
+
End Class
|
63
|
+
|
64
|
+
```
|
65
|
+
ここでは商品数3までですが実際は60まで作成しました。また最終的な合計はButtonを押すとTextBoxに表示される仕組みで考えています。修正完了しましたよろしくお願いします。
|