Cov txheej txheem:

Tsim Txoj Haujlwm Hauv Visual Basic: Web Browser: 9 Kauj Ruam
Tsim Txoj Haujlwm Hauv Visual Basic: Web Browser: 9 Kauj Ruam

Video: Tsim Txoj Haujlwm Hauv Visual Basic: Web Browser: 9 Kauj Ruam

Video: Tsim Txoj Haujlwm Hauv Visual Basic: Web Browser: 9 Kauj Ruam
Video: Как работает SEO | Простая структура дорожной карты SEO 2024, Kaum ib hlis
Anonim
Tsim Txoj Haujlwm hauv Visual Basic: Web Browser
Tsim Txoj Haujlwm hauv Visual Basic: Web Browser

Cov Lus Qhia no piav qhia tus txheej txheem ntawm kev tsim lub vev xaib yooj yim thov hauv VB. NETIt yog tsim los ua raws kuv qab VB. NET thawj zaug Qhia: Tsim Koj Thawj Qhov Kev Kawm Hauv Visual Basic. Nws tau pom zoo tias koj nyeem dhau qhov kev qhia ua ntej, raws li cov lus qhia no xav tias koj muaj kev paub pib ntawm Visual Basic Express Edition Interface, raws li tau hais hauv kuv lwm qhov kev qhia. Visual Basic 2008 Express Edition, muaj los ntawm Microsoft

Kauj Ruam 1: Tsim Txoj Haujlwm

Tsim Txoj Haujlwm
Tsim Txoj Haujlwm

Tsim qhov tshiab Windows Forms Project, thiab hu nws Web Browser. Resize daim ntawv rau koj nyiam.

Kauj Ruam 2: Ntxiv Cov Kev Tswj, thiab Hloov Cov Khoom

Ntxiv Cov Kev Tswj, thiab Hloov Cov Khoom
Ntxiv Cov Kev Tswj, thiab Hloov Cov Khoom

Los ntawm lub cuab yeej, rub TextBox, WebBrowser thiab A Button mus rau hauv daim ntawv. Muab lawv zoo li lawv nyob hauv daim duab. Tom qab ntawd, hloov kho Thauj Khoom cov cuab yeej ntawm TextBox thiab WebBrowser kom tag nrho cov thawv nyob ib puag ncig lub xwmfab grey (qhia thaum koj hloov kho cov khoom thauj tog rau nkoj) raug xaiv, qhov no yuav tso cai rau kev tswj kom 'ncab' thaum daim ntawv hloov pauv. Ua tib yam rau Khawm, tab sis tsuas yog teeb nws rau "Sab Saum, Txoj Cai". Txhua yam hloov cov ntawv Cov cuab yeej ntawm Form1 rau Web Browser, lossis qee yam zoo sib xws los hloov lub npe kab.

Kauj ruam 3: Code

Code!
Code!

Nyem ob npaug rau ntawm Button1, thiab ntxiv cov cai hauv qab no rau tus editor, tom qab kab "Ntiag Tug" thiab ua ntej kab "End Sub"

WebBrowser1. Navigate (TextBox1. Text)Txoj cai no yooj yim qhia txoj haujlwm: Thaum ib tus neeg nyem khawm 1, Tau WebBrowser Txhawm rau Nkag mus rau txhua yam uas nyob hauv TextBox1 Ntawd Yog! Koj muaj lub web browser ua haujlwm. Nias lub pob ua si los sim nws.

Kauj Ruam 4: Ntau Yam

Ntau Yam
Ntau Yam

Tam sim no, koj tsis xav tias kuv tsuas yog yuav muab ib kab rau koj - puas yog? Hla ob peb kauj ruam tom ntej, peb yuav siv cov hauv qab no:

  • Qhov chaw nyob bar uas hloov pauv thaum nplooj ntawv hloov pauv
  • Rov qab, rau pem hauv ntej thiab hloov kho cov nyees khawm
  • Qhov xwm txheej bar.

Kauj Ruam 5: Chaw Nyob

Chaw Nyob Bar
Chaw Nyob Bar

Tam sim no, txhua qhov chaw nyob bar qhia tawm nplooj ntawv uas koj ntaus, yog tias koj nyem rau ntawm qhov txuas, qhov kev hloov pauv tsis cuam tshuam rau hauv qhov chaw nyob bar. Txhawm rau kho qhov no, peb yuav tsum tau ntxiv qee qhov chaws rov qab mus rau qhov tsim qauv, nyem rau ntawm "Form 1.vb (Tsim)" thiab tom qab ntawd ob npaug nyem rau ntawm WebBrowser tswj. Nws yuav hloov rov qab mus rau txoj cai saib, txawm li cas los yuav muaj qee qhov chaws ntxiv, ceeb toom tias nws hais tias "WebBrowser1_DocumentCompleted", qhov no yog tus lej peb xav tau, yog li peb tsis tas yuav hloov dab tsi ntawm no, tab sis muaj qhov khoob kab hauv qab qhov ntawd, ua ntej End Sub nqe lus, thiab peb xav ntxiv qee qhov chaws nyob ntawd. Ntaus cov ntawv hauv qab no

TextBox1. Text = WebBrowser1. Url. ToStringQhov no qhia qhov haujlwm uas ib zaug WebBrowser1_DocumentCompleted, peb yuav tsum hloov TextBox1. Text rau WebBrowser1. Url. ToString nyob ntawd vim tias, los ntawm lub neej ntawd, cov cuab yeej URL ntawm lub vev xaib tsis zoo ib yam cov ntaub ntawv (hlua), raws li xav tau los ntawm peb lub thawv ntawv. ToString sau qhov URL rau txoj hlua rau TextBox.

Kauj Ruam 6: Nqis Tes Ua

Khawm Ua
Khawm Ua

Hloov rov qab los tsim saib thiab luag 3 lub nyees khawm tshiab rau hauv daim ntawv thiab tso lawv. Hloov Cov Ntawv Cov Khoom ntawm txhua tus: Button2 = Back, Button3 = Forward thiab Button4 = Refresh. Yog tias koj tso lawv zoo li kuv, kho cov khoom thauj tog rau nkoj ntawm Refresh to Top, RightDouble nyem rau ntawm Lub Pob Rov Qab, thiab ntaus cov cai hauv qab no.

WebBrowser1. GoBack () Rov qab rau kev tsim, ob npaug nias rau Forward thiab ntaus ntawv

WebBrowser1. GoForward ()Tsim kev pom, thiab ob npaug nyem rau Refresh

WebBrowser1. Refresh ()Kuaj qhov browser, thiab sim tawm cov yam ntxwv tshiab.

Kauj Ruam 7: Status Bar

Status Bar
Status Bar

Rov qab rau hauv kev tsim qauv, ntxiv daim ntawv lo, hloov Cov Ntawv rau "Chaw thau khoom …" (yam tsis muaj nqe lus) Tam sim no, mus rau hauv txoj cai saib los txhaj rau ntawm Form1.vb tab. Nrhiav WebBrowser1_DocumentCompleted nkag thiab ntaus hauv qab cov cai koj tau tso rau ntawd ua ntej

Label1. Text = "Ua tiav"Tam sim no, nyem rau ntawm qhov chaws hais tias DocumentCompleted. Tsiv koj tus nas mus rau qhov uas ob lub thawv tso rau hauv. Xaiv qhov thib ob (Qhov uas hais tias DocumentCompleted) thiab xaiv Navigating. Tom qab ntawd, qee qhov cai tshiab yuav tshwm sim - ntaus ntawv

Label1. Text = "Chaw thau khoom"Qhov no tsuas yog muab qhov taw qhia thaum nplooj ntawv tab tom thauj khoom.

Kauj ruam 8: Comlete

Comlete!
Comlete!

Koj mus. Koj muaj lub web browser ua haujlwm tau zoo. Khaws ntawm kev kho nws raws li koj xav tau. Zoo li hauv kuv thawj qhov kev qhia. Kuv muaj qee cov ntawv ua tom tsev rau cov uas ua tiav cov lus qhia no. Kuv ua raws li hauv qab no:

  • Kev ua haujlwm hauv tsev
  • Hloov qhov Hloov Tshiab khawm mus rau Nres Nres thaum nplooj ntawv rub tawm.

Kuv vam tias cov haujlwm no tau qhia koj yooj yim npaum li cas rau txoj haujlwm!

Kauj Ruam 9: Kev daws teeb meem

Daws teeb meem
Daws teeb meem

Rau cov uas ua tiav kuv thawj VB cov lus qhia - Kuv muaj cov kev daws rau cov ntawv ua tom tsev kuv teeb tsa thaum kawg.

Hloov xim tom qab

Nov yog qhov yooj yim - Hloov cov khoom BackColour ntawm Form1 rau xim sib txawv

Ntxiv qee cov ntaub ntawv ntiag tug

Ib daim ntawv tshiab nrog cov khoom hloov pauv yuav ua qhov dag

Ua daim ntawv hloov me me nrog Daim Duab

Hloov AutoSize kom tseeb thiab AutoSizeMode rau GrowAndShrinkDone! Tseem yuav los: Kuv yuav tsim qee qhov ntxiv VB. NET Cov Lus Qhia Khaws Coding!

Pom zoo: