步驟1:創(chuàng)建項目


步驟1:打開 Microsoft Visual Basic。
步驟2:通過單擊創(chuà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)制作了一個‘ 500,300’ 。
第7步:在表格頂部插入標(biāo)簽,然后將命名為“ 標(biāo)題 ”,并輸入文字“ 長度 轉(zhuǎn)換器 “
第8步:插入兩個按鈕。一個在中心。將其命名為“ ConvertButton ”,并輸入文字“ Convert ”。 第二個按鈕是可選的。 將其放在右上角,并將其命名為“ ExitButton ”,并輸入文字“ Exit 》“
步驟9:插入兩個ComboBox,將其中一個放置在左側(cè),將另一個放置在右側(cè)。在左側(cè)命名為“ LengthList1 ”,在右側(cè)命名為“ LengthList2 ”。使它們兩個上的文字均為“ 選擇 單位 ”
第10步:插入兩個文本框并將其放置在組合框下方。將它們命名為“ UnitText1 ”和“ UnitText2 ”。將文本留空。
步驟2:獲取基本代碼

步驟11:雙擊‘ExitButton’。
步驟12:插入以下代碼:‘This will close the application’
Me.Close() 步驟13:雙擊點擊“轉(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文章
9420瀏覽量
156419 -
VisualBasic
+關(guān)注
關(guān)注
0文章
6瀏覽量
6908
發(fā)布評論請先 登錄
探索MAX17291B高電壓微功率升壓轉(zhuǎn)換器的設(shè)計奧秘
解析LTC3523:同步升降壓DC/DC轉(zhuǎn)換器的卓越之選
ESS中的雙向CLLLC諧振轉(zhuǎn)換器的控制方案
北斗信號轉(zhuǎn)發(fā)器 多通道GNSS衛(wèi)星信號轉(zhuǎn)發(fā)器介紹 gps信號轉(zhuǎn)換器
如何使用多相升壓轉(zhuǎn)換器
國產(chǎn)電平轉(zhuǎn)換器雙雄登場!GS0104/GS0108 如何破解多場景電壓適配難題?
AP61300/AP61302:高效同步降壓轉(zhuǎn)換器的深度剖析與應(yīng)用指南
如何有效減少降壓轉(zhuǎn)換器中的電磁干擾(EMI)?
一文詳解高速模數(shù)轉(zhuǎn)換器的奈奎斯特規(guī)則
TI電源設(shè)計小貼士 | 設(shè)計DCM反激式轉(zhuǎn)換器
USB轉(zhuǎn)485/422轉(zhuǎn)換器拆解
如何在VisualBasic中制作長度轉(zhuǎn)換器
評論