Qhov wikiHow no qhia koj li cas los tsim qhov program Visual Basic yooj yim uas tso cai rau koj nrhiav cov lej ntawm ob tus lej. Txhawm rau kom ua tiav koj txoj haujlwm, koj yuav xav tau Visual Basic compiler xws li Visual Studio 2017.
Cov kauj ruam
Kauj Ruam 1. Qhib qhov koj nyiam Visual Basic editor
Yog tias koj xav sim koj txoj haujlwm tom qab, nco ntsoov tias koj muaj ib txoj haujlwm uas txhawb kev debugging (piv txwv li, Visual Basic 2017).
Yog tias koj tsis muaj Visual Basic editor, koj tuaj yeem siv Notepad ++ lossis rub tawm qhov program Visual Basic 2017
Kauj Ruam 2. Ntxiv kab thawj zaug
Ntaus Tus Kheej Ntiag Tug Form1 rau hauv Visual Basic editor, tom qab ntawd nias ↵ Enter. Qhov no teeb tsa qhov seem ntawm koj daim ntawv.
Cov ntawv "Tus Kheej Ntiag Tug" hauv Visual Basic zoo ib yam li "" cim npe hauv HTML
Kauj Ruam 3. Teeb koj daim ntawv kom paub txog qhov txawv
Txij li koj yuav tau ntxiv ob qhov sib ntxiv ua ke txhawm rau nrhiav qhov sib tw, koj yuav tsum tau ua kom pom qhov Visual Basic kom paub tus lej ua qhov hloov pauv. Ua li ntawd:
- Ntaus hauv Tus Kheej Ntiag Tug 1_Click (xa raws li Lub Hom Phiaj, e Raws li EventArgs) thiab nias ↵ Enter.
- Ntaus hauv Handle (Button1_Click) thiab nias ↵ Enter.
- Ntaus hauv Dim sum Raws Li Integer thiab nias ↵ Enter.
- Ntaus hauv Dim a As Integer thiab nias ↵ Enter.
- Ntaus hauv Dim b Raws Li Integer thiab nias ↵ Enter.
Kauj Ruam 4. Tsim kev zam rau cov ntawv ntawv
Qhov no yuav ua rau koj qhov program ua rau muaj qhov yuam kev yog tias koj tsis sau rau hauv ib lub thawv. Ua li ntawd:
- Ntaus hauv Label4. Visible = True thiab nias ↵ Enter.
- Ntaus hauv Yog TextBox1. Text = "" Tom qab ntawd thiab nias ↵ Enter.
- Ntaus hauv Label4. Visible = Cuav thiab nias ↵ Enter.
- Ntaus hauv MessageBox. Show ("Thov txim, lub thawv tsis tuaj yeem khoob.") Thiab nias ↵ Enter.
- Ntaus hauv TextBox1. Focus () thiab nias ↵ Enter.
- Ntaus qhov kawg Yog thiab nias ↵ Enter.
Kauj Ruam 5. Tsim cov thawv ntawv rau koj tus lej
Qhov no yuav yog lub interface uas koj siv los sau koj tus lej. Ua li ntawd:
- Ntaus hauv a = Val (TextBox1. Text) thiab nias ↵ Enter.
- Ntaus hauv b = Val (TextBox2. Text) thiab nias ↵ Enter.
- Ntaus hauv sum = (a + b) thiab nias ↵ Enter.
- Ntaus hauv Label4. Text = "Qhov sib npaug ntawm" & a & "thiab" & b & "yog" & sum & "." thiab nias ↵ Enter.
Kauj Ruam 6. Xaus qhov khawm-nyem ntu
Ntaus hauv End Sub thiab nias ↵ Enter.
Kauj Ruam 7. Tsim ntu tshiab
Ntaus hauv Tus Kheej Sub Form1_Load (xa raws li Lub Hom Phiaj, e li EventArgs) Ua Haujlwm MyBase. Load thiab nias ↵ Enter.
Kauj Ruam 8. Ntxiv daim ntawv qhia tsis tseeb
Ntaus hauv Label4. Visible = Cuav thiab nias ↵ Enter, tom qab ntawd ntaus hauv End Sub thiab nias ↵ Enter.
Kauj Ruam 9. Tsim ntu kawg
Ntaus hauv Tus Kheej Ntiag2 Button2_Click (xa raws li Lub Hom Phiaj, e Raws li EventArgs) Handles Button2. Click thiab nias ↵ Enter.
Kauj Ruam 10. Ntxiv cov neeg ua pov thawj rau cov thawv ntawv
Qhov no yuav tso cai koj ntxiv tus lej hauv koj qhov kev kawm tiav. Ua li ntawd:
- Ntaus hauv TextBox1. Text = "" thiab nias ↵ Enter.
- Ntaus hauv TextBox2. Text = "" thiab nias ↵ Enter.
- Ntaus hauv Label4. Text = "" thiab nias ↵ Enter.
- Ntaus hauv TextBox1. Focus () thiab nias ↵ Enter.
Kauj Ruam 11. Tsim cov lus "ntxiv"
Ntaus hauv Sum = Val (TextBox1. Text) + Val (TextBox2. Text) thiab nias ↵ Enter.
Kauj Ruam 12. Ntxiv qhov "sum" hais kom ua
Ntaus hauv TextBox3. Text = Sum thiab nias ↵ Enter.
Kauj Ruam 13. Kaw txoj cai
Ntaus hauv End Sub thiab nias ↵ Nkag mus kaw ntu kawg, tom qab ntawd ntaus hauv End Class kom kaw tag nrho txoj haujlwm.
Kauj Ruam 14. Debug koj qhov program
Nyem rau Debug tab, click Pib Debugging, thiab tos kom cov txheej txheem debugging kom tiav. Thaum koj qhov program tau debugged tag lawm, lub qhov rai nrog peb lub thawv ntawv thiab ib lub pob ntxiv yuav tsum qhib; tom qab ntawd koj tuaj yeem ntxiv tus lej rau ob lub npov saum toj kawg nkaus thiab nyem lub pob kom ntxiv cov lej ua ke.
- Yog tias koj siv cov ntawv sau yooj yim los tsim koj li Visual Basic code, koj yuav tsis muaj Debug tab. Txiav txim siab qhib koj txoj haujlwm hauv Visual Studio 2017 kom debug thiab ua haujlwm.
- Yog tias koj siv Notepad lossis TextEdit los tsim koj tus lej, nco ntsoov khaws cov ntaub ntawv kawg hauv ".vb" hom es tsis yog ".txt" lossis ".text".
Lub tswv yim
- Visual Studio 2017 yog rub tawm dawb los ntawm Microsoft lub vev xaib.
- Thaum siv cov apps zoo li Notepad lossis TextEdit, nws pab rau indent tus kheej cov ntu tshwj xeeb ntawm cov lej kom koj tuaj yeem pom yooj yim dua qhov sib txawv ntawm qhov haujlwm.