teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

ソースコード記載しました

2019/06/04 05:57

投稿

gyaSon
gyaSon

スコア16

title CHANGED
File without changes
body CHANGED
@@ -24,4 +24,147 @@
24
24
 
25
25
  レートは下記の通りで宣言しています。
26
26
  $=108
27
- €=120
27
+ €=120
28
+
29
+ ###その後
30
+ 求めておりました動作は何とかできるようになりました。
31
+ zuishinさんのアドバイスを組めたかどうかですが・・・。
32
+
33
+ ソースコード記載いたします。
34
+ ```Public Class Form1
35
+ Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
36
+
37
+ Dim strData() As String = {"\", "$", "€"}
38
+ 'コンボボックスにアイテムを追加する
39
+ ComboBox1.Items.AddRange(strData)
40
+ ComboBox2.Items.AddRange(strData)
41
+ ComboBox3.Items.AddRange(strData)
42
+
43
+ End Sub
44
+
45
+
46
+ Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click '円に変換
47
+ Dim Dollar As String = 108
48
+ Dim EUR As String = 120
49
+
50
+ 'テキストボックス1の円変換
51
+
52
+ If ComboBox1.SelectedIndex = 0 Then
53
+ Label1.Text = ("\" & TextBox1.Text)
54
+ ElseIf ComboBox1.SelectedIndex = 1 Then
55
+ Label1.Text = ("\" & TextBox1.Text * Dollar)
56
+ ElseIf ComboBox1.SelectedIndex = 2 Then
57
+ Label1.Text = ("\" & TextBox1.Text * EUR)
58
+ End If
59
+
60
+ 'テキストボックス2を円変換
61
+
62
+ If ComboBox2.SelectedIndex = 0 Then
63
+ Label2.Text = ("\" & TextBox2.Text)
64
+ ElseIf ComboBox2.SelectedIndex = 1 Then
65
+ Label2.Text = ("\" & TextBox2.Text * Dollar)
66
+ ElseIf ComboBox2.SelectedIndex = 2 Then
67
+ Label2.Text = ("\" & TextBox2.Text * EUR)
68
+ End If
69
+
70
+ 'テキストボックス3を円変換
71
+
72
+ If ComboBox3.SelectedIndex = 0 Then
73
+ Label3.Text = ("\" & TextBox3.Text)
74
+ ElseIf ComboBox3.SelectedIndex = 1 Then
75
+ Label3.Text = ("\" & TextBox3.Text * Dollar)
76
+ ElseIf ComboBox3.SelectedIndex = 2 Then
77
+ Label3.Text = ("\" & TextBox3.Text * EUR)
78
+ End If
79
+ End Sub
80
+
81
+ Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click '$に変換
82
+ Dim Dollar As String = 108
83
+ Dim EUR As String = 120
84
+
85
+ 'テキストボックス1のドル変換
86
+
87
+ If ComboBox1.SelectedIndex = 0 Then
88
+ Label1.Text = Format((TextBox1.Text / Dollar), "0.00")
89
+ Label1.Text = CStr("$" & Label1.Text)
90
+ ElseIf ComboBox1.SelectedIndex = 1 Then
91
+ Label1.Text = CStr("$" & TextBox1.Text)
92
+ ElseIf ComboBox1.SelectedIndex = 2 Then
93
+ Label1.Text = Format((TextBox1.Text * EUR / Dollar), "0.00")
94
+ Label1.Text = CStr("$" & Label1.Text)
95
+ End If
96
+
97
+ 'テキストボックス2をドル変換
98
+
99
+ If ComboBox2.SelectedIndex = 0 Then
100
+ Label2.Text = Format((TextBox2.Text / Dollar), "0.00")
101
+ Label2.Text = CStr("$" & Label2.Text)
102
+ ElseIf ComboBox2.SelectedIndex = 1 Then
103
+ Label2.Text = CStr("$" & TextBox2.Text)
104
+ ElseIf ComboBox2.SelectedIndex = 2 Then
105
+ Label2.Text = Format((TextBox2.Text * EUR / Dollar), "0.00")
106
+ Label2.Text = CStr("$" & Label2.Text)
107
+ End If
108
+
109
+ 'テキストボックス3をドル変換
110
+
111
+ If ComboBox3.SelectedIndex = 0 Then
112
+ Label3.Text = Format((TextBox3.Text / Dollar), "0.00")
113
+ Label3.Text = CStr("$" & Label3.Text)
114
+ ElseIf ComboBox3.SelectedIndex = 1 Then
115
+ Label3.Text = CStr("$" & TextBox3.Text)
116
+ ElseIf ComboBox3.SelectedIndex = 2 Then
117
+ Label3.Text = Format((TextBox3.Text * EUR / Dollar), "0.00")
118
+ Label3.Text = CStr("$" & Label3.Text)
119
+ End If
120
+ End Sub
121
+
122
+ Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click '€に変換
123
+
124
+ Dim Dollar As String = 108
125
+ Dim EUR As String = 120
126
+
127
+ 'テキストボックス1のユーロ変換
128
+
129
+ If ComboBox1.SelectedIndex = 0 Then
130
+ Label1.Text = Format((TextBox1.Text / EUR), "0.00")
131
+ Label1.Text = CStr("€" & Label1.Text)
132
+ ElseIf ComboBox1.SelectedIndex = 1 Then
133
+ Label1.Text = Format((TextBox1.Text * Dollar / EUR), "0.00")
134
+ Label1.Text = CStr("€" & Label1.Text)
135
+ ElseIf ComboBox1.SelectedIndex = 2 Then
136
+ Label1.Text = CStr("€" & TextBox1.Text)
137
+ End If
138
+
139
+ 'テキストボックス2をユーロ変換
140
+
141
+ If ComboBox2.SelectedIndex = 0 Then
142
+ Label2.Text = Format((TextBox2.Text / EUR), "0.00")
143
+ Label2.Text = CStr("€" & Label2.Text)
144
+ ElseIf ComboBox2.SelectedIndex = 1 Then
145
+ Label2.Text = Format((TextBox2.Text * Dollar / EUR), "0.00")
146
+ Label2.Text = CStr("€" & Label2.Text)
147
+ ElseIf ComboBox2.SelectedIndex = 2 Then
148
+ Label2.Text = CStr("€" & TextBox2.Text)
149
+ End If
150
+
151
+ 'テキストボックス3をユーロ変換
152
+
153
+ If ComboBox3.SelectedIndex = 0 Then
154
+ Label3.Text = Format((TextBox3.Text / EUR), "0.00")
155
+ Label3.Text = CStr("€" & Label3.Text)
156
+ ElseIf ComboBox3.SelectedIndex = 1 Then
157
+ Label3.Text = Format((TextBox3.Text * Dollar / EUR), "0.00")
158
+ Label3.Text = CStr("€" & Label3.Text)
159
+ ElseIf ComboBox3.SelectedIndex = 2 Then
160
+ Label3.Text = CStr("€" & TextBox3.Text)
161
+ End If
162
+ End Sub
163
+
164
+ End Class
165
+
166
+ ```
167
+ ここから省く、もしくはより分かりやすくまとめる方法が
168
+ あるのでしょうが今の私の知識ではこれで何とかというところです。
169
+
170
+ 御助力をお願いいたします。