Dokumen lama yang lalu, diselesaikan dan mengenang
Gunakan VB untuk merangkum ASP dan membuat program tes Sayhello
1. Buka VB6 dan buat ActiveXdll baru
2. Tambahkan Microsoft ActiveServerPagesObjectLibrary ke referensi proyek
3. Isi kode sebagai berikut:
'Codestart
'Bagian Deklarasi
PrivateMyScriptingContextAssCriptingContext
PrivatemyApplicationAsApplication
PrivatemyRequestasRequest
PrivatemyResponseasResponse
PrivatemyServerServer
PrivatemySessionAssession
'The following defines a common function (accessing the ASP object in VB, that is, in VB, MyApplication can be used to be equivalent to Application in ASP, MyRequest is equivalent to Request in ASP, MyResponse is equivalent to Response in ASP, MyServer is equivalent to Server in ASP, MySession is equivalent to Session in ASP)
Publicsubonstartpage (lulus scriptingcontexsasscriptingcontext)
SetMyScriptingContext = lulus scriptingcontext
SetMyApplication = myscriptingContext.application
SetMyRequest = myscriptingcontext.Request
SetMyResponse = myscriptingcontext.response
SetMyServer = myscriptingcontext.server
SetMySession = myscriptingcontext.Session
Endsub
Publicsubonendpage ()
SetMyScriptingContext = tidak ada
SetMyApplication = tidak ada
SetMyRequest = tidak ada
SetMyResponse = tidak ada
SetMyServer = tidak ada
SetMySession = tidak ada
Endsub
'Buat fungsi khusus Sayhello
Publicsubsayhello ()
MyResponse.write ("HelloWorld")
Endsub
'Codeend
4. Ubah Nama Kelas menjadi: HelloWorld Ubah Nama Proyek ke: TestVBCode
5. Hasilkan file testvbcode.dll dan gunakan Windows untuk menjalankan path REGSVR32/testVbCode.dll untuk mendaftar dan menggunakannya. (Perintah komponen uninstall adalah regsvr32/u path/testvbcode.dll)
6. Buat file test.asp, kodenya adalah sebagai berikut
<%
'VB Format Panggilan Fungsi Self-Built
'Setel Object Name = Server.CreateObject ("Nama Proyek. Nama kelas")
'Nama objek. Nama fungsi yang dibangun sendiri
SetMytestoBj = server.CreateObject ("testvbcode.helloworld")
Mytestobj.sayhello
%>
7. Hasil menjalankan file test.asp ditampilkan sebagai berikut:
Helloworld
Contoh di atas akan membuka pintu ke dunia pemrograman VB Anda
Ayo berkumpul, haha!