步驟1:創(chuàng)建項(xiàng)目
步驟1:打開(kāi) Microsoft Visual Basic。
步驟2:通過(guò)單擊創(chuàng)建新項(xiàng)目新項(xiàng)目 或按 Ctrl + N 。
步驟3:選擇 Windows窗體應(yīng)用程序 ,并將其命名為“ Length Converter ”。
步驟4:重命名 Form1.vb 更改為“ Length.vb ”。 這是易于使用的方法。
步驟5:將 Form1 重命名為“ LengthForm ”,并將文本設(shè)置為“ Length Converter ”。 這是易于使用的方法。
步驟6:根據(jù)自己的喜好調(diào)整大小。我已經(jīng)制作了一個(gè)‘ 500,300’ 。
第7步:在表格頂部插入標(biāo)簽,然后將命名為“ 標(biāo)題 ”,并輸入文字“ 長(zhǎng)度 轉(zhuǎn)換器 “
第8步:插入兩個(gè)按鈕。一個(gè)在中心。將其命名為“ ConvertButton ”,并輸入文字“ Convert ”。 第二個(gè)按鈕是可選的。 將其放在右上角,并將其命名為“ ExitButton ”,并輸入文字“ Exit 》“
步驟9:插入兩個(gè)ComboBox,將其中一個(gè)放置在左側(cè),將另一個(gè)放置在右側(cè)。在左側(cè)命名為“ LengthList1 ”,在右側(cè)命名為“ LengthList2 ”。使它們兩個(gè)上的文字均為“ 選擇 單位 ”
第10步:插入兩個(gè)文本框并將其放置在組合框下方。將它們命名為“ UnitText1 ”和“ UnitText2 ”。將文本留空。
步驟2:獲取基本代碼
步驟11:雙擊‘ExitButton’。
步驟12:插入以下代碼:‘This will close the application’
Me.Close() 步驟13:雙擊點(diǎn)擊“轉(zhuǎn)換按鈕”。
步驟14:插入以下代碼:
‘These are the Boolean for the Length in the first box’
Dim Mile1 As Boolean
Dim KM1 As Boolean
Dim M1 As Boolean
Dim CM1 As Boolean
‘These are the Boolean for the length in the second box’
Dim Mile2 As Boolean
Dim KM2 As Boolean
Dim M2 As Boolean
Dim CM2 As Boolean
‘These are the inserted numbers that will be converted’
Dim Num1 As String
Num1 = UnitText1.Text
Dim Num1 As String
Num2 = UnitText2.Text
步驟3 :轉(zhuǎn)換單位
步驟15:在先前的代碼下方插入以下內(nèi)容:
‘What it is converting’
If LengthList1.Text = (“Mile”) And LengthList2.Text = (“Kilometre”) Then
Mile1 = True
KM2 = True
End If
‘The equation for the conversion’
If Mile1 = True and KM2 = True Then
UnitText2.Text = Num1 / 0.62137
End If
If LengthList1.Text = (“Mile”) And LengthList2.Text = (“Metre”) Then
Mile1 = True
M2 = True
End If
If Mile1 = True and M2 = True Then
UnitText2.Text = Num1 / 0.0062137
End If
If LengthList1.Text = (“Mile”) And LengthList2.Text = (“Centimetre”) Then
Mile1 = True
CM2 = True
End If
If Mile1 = True and CM2 = True Then
UnitText2.Text = Num1 / 0.0000062137
End If
If LengthList1.Text = (“Kilometre”) And LengthList2.Text = (“Mile”) Then
KM1 = True
Mile2 = True
End If
If KM1 = True and Mile2 = True Then
UnitText2.Text = Num1 * 0.62137
End If
If LengthList1.Text = (“Kilometre”) And LengthList2.Text = (“Metre”) Then
KM1 = True
M2 = True
End If
If KM1 = True and M2 = True Then
UnitText2.Text = Num1 / 0.001
End If
If LengthList1.Text = (“Kilometre”) And LengthList2.Text = (“Centimetre”) Then
KM1 = True
CM2 = True
End If
If KM1 = True and CM2 = True Then
UnitText2.Text = Num1 / 0.000001
End If
If LengthList1.Text = (“Metre”) And LengthList2.Text = (“Mile”) Then
M1 = True
Mile2 = True
End If
If M1 = True and Mile2 = True Then
UnitText2.Text = Num1 * 0.000621317
End If
If LengthList1.Text = (“Metre”) And LengthList2.Text = (“Kilometre”) Then
M1 = True
KM2 = True
End If
If M1 = True and KM2 = True Then
UnitText2.Text = Num1 / 1000
End If
If LengthList1.Text = (“Metre”) And LengthList2.Text = (“Centimetre”) Then
M1 = True
CM2 = True
End If
If M1 = True and CM2 = True Then
UnitText2.Text = Num1 / 0.01
End If
If LengthList1.Text = (“Centimetre”) And LengthList2.Text = (“Mile”) Then
CM1 = True
Mile2 = True
End If
If CM1 = True and Mile2 = True Then
UnitText2.Text = Num1 * 0.000000621317
End If
If LengthList1.Text = (“Centimetre”) And LengthList2.Text = (“Kilometre”) Then
CM1 = True
KM2 = True
End If
If CM1 = True and KM2 = True Then
UnitText2.Text = Num1 * 0.00001
End If
If LengthList1.Text = (“Centimetre”) And LengthList2.Text = (“Metre”) Then
CM1 = True
M2 = True
End If
If CM1 = True and M2 = True Then
UnitText2.Text = Num1 * 0.01
End If
‘If converting into same unit then the valve will be the same’
If LengthList1.Text = LengthList2.Text Then
UnitText2.Text = Num1
End If
-
轉(zhuǎn)換器
+關(guān)注
關(guān)注
27文章
8745瀏覽量
148059 -
VisualBasic
+關(guān)注
關(guān)注
0文章
6瀏覽量
6723
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
電能轉(zhuǎn)換的核心,儲(chǔ)能中的AC/DC轉(zhuǎn)換器控制芯片
HDMI接口轉(zhuǎn)換器的使用技巧
數(shù)模轉(zhuǎn)換器在音頻設(shè)備中的應(yīng)用
如何在反激式轉(zhuǎn)換器中緩沖FET關(guān)斷電壓
![如<b class='flag-5'>何在</b>反激式<b class='flag-5'>轉(zhuǎn)換器</b><b class='flag-5'>中</b>緩沖FET關(guān)斷電壓](https://file1.elecfans.com/web2/M00/0A/C1/wKgZomcoKCOAD9L0AAA2em4EETc765.png)
快速輸入轉(zhuǎn)換速率應(yīng)用中DC-DC轉(zhuǎn)換器的設(shè)計(jì)注意事項(xiàng)
![快速輸入<b class='flag-5'>轉(zhuǎn)換</b>速率應(yīng)用<b class='flag-5'>中</b>DC-DC<b class='flag-5'>轉(zhuǎn)換器</b>的設(shè)計(jì)注意事項(xiàng)](https://file.elecfans.com/web1/M00/D9/4E/pIYBAF_1ac2Ac0EEAABDkS1IP1s689.png)
同軸轉(zhuǎn)換器為什么容易壞 同軸轉(zhuǎn)換器對(duì)音質(zhì)的影響
什么是DC/DC轉(zhuǎn)換器?
降壓轉(zhuǎn)換器中的低壓差操作
![降壓<b class='flag-5'>轉(zhuǎn)換器</b><b class='flag-5'>中</b>的低壓差操作](https://file.elecfans.com/web1/M00/D9/4E/pIYBAF_1ac2Ac0EEAABDkS1IP1s689.png)
降低汽車降壓轉(zhuǎn)換器應(yīng)用中的傳導(dǎo)EMI
![降低汽車降壓<b class='flag-5'>轉(zhuǎn)換器</b>應(yīng)用<b class='flag-5'>中</b>的傳導(dǎo)EMI](https://file.elecfans.com/web1/M00/D9/4E/pIYBAF_1ac2Ac0EEAABDkS1IP1s689.png)
轉(zhuǎn)換器供電和不供電什么區(qū)別
![](https://file1.elecfans.com/web2/M00/EE/6C/wKgaomZrebWARnI0AAGjZPHjN2w419.png)
PWM技術(shù)如何控制功率轉(zhuǎn)換器
SDI轉(zhuǎn)AV轉(zhuǎn)換器在影視制作中的應(yīng)用及其實(shí)踐
個(gè)性化高清視頻轉(zhuǎn)換器:為視頻制作提供專業(yè)級(jí)解決方案
![個(gè)性化高清視頻<b class='flag-5'>轉(zhuǎn)換器</b>:為視頻<b class='flag-5'>制作</b>提供專業(yè)級(jí)解決方案](https://file1.elecfans.com/web2/M00/C0/95/wKgZomXW6LWALUpQAACtUSxZ2p8230.jpg)
dcdc降壓轉(zhuǎn)換器工作原理
![dcdc降壓<b class='flag-5'>轉(zhuǎn)換器</b>工作原理](https://file1.elecfans.com/web2/M00/C0/90/wKgaomW9l0qAPWp6AAFuOSEJtD0955.jpg)
評(píng)論