Форум программистов, компьютерный форум, киберфорум
Visual Basic
Войти
Регистрация
Восстановить пароль
 
Рейтинг 4.91/11: Рейтинг темы: голосов - 11, средняя оценка - 4.91
0 / 0 / 0
Регистрация: 10.04.2007
Сообщений: 96
1

Примеры CGI на Visual Basic

10.04.2007, 03:51. Показов 2276. Ответов 3
Метки нет (Все метки)

Где можно найти примеры CGI на Visual Basic (на русском языке)? Есть ли такая литература?
__________________
Помощь в написании контрольных, курсовых и дипломных работ здесь
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
10.04.2007, 03:51
Ответы с готовыми решениями:

IIS + CGI + Visual Basic = стучимся об UTF?
Такая проблема: Сделал CGI на Visual Basicе - принимает некое слово из веб-формы и тут же выдает...

Математические примеры в Visual Basic 6.0
Всем привет, не могу прописать примеры, чтобы был правильный ответ. Помогите, пожалуйста! ...

Примеры программ на Visual Basic
Народ, кому не лень, киньте пару примерчиков на просмотр возможностей данного языка. Думаю тема...

Примеры SQL запросов к базе данных через оболочку Visual Basic да и других языков
Примеры SQL запросов к базе данных через оболочку Visual Basic да и других языков. Довольно часто я...

3
Anri
10.04.2007, 12:54 2
Вот пример CGI на VB:
делай модуль CGI4VB.bas:
'====================================
' CGI4VB.BAS
'====================================
Option Explicit
'
' CGI routines used with VB 4.0 (32bit) using STDIN / STDOUT.
'
' Version: 1.4 (December 1996)
'

Declare Function GetStdHandle Lib 'kernel32' _
(ByVal nStdHandle As Long) As Long
Declare Function ReadFile Lib 'kernel32' _
(ByVal hFile As Long, _
lpBuffer As Any, _
ByVal nNumberOfBytesToRead As Long, _
lpNumberOfBytesRead As Long, _
lpOverlapped As Any) As Long
Declare Function WriteFile Lib 'kernel32' _
(ByVal hFile As Long, _
ByVal lpBuffer As String, _
ByVal nNumberOfBytesToWrite As Long, _
lpNumberOfBytesWritten As Long, _
lpOverlapped As Any) As Long
Declare Function SetFilePointer Lib 'kernel32' _
(ByVal hFile As Long, _
ByVal lDistanceToMove As Long, _
lpDistanceToMoveHigh As Long, _
ByVal dwMoveMethod As Long) As Long
Declare Function SetEndOfFile Lib 'kernel32' _
(ByVal hFile As Long) As Long

Public Const STD_INPUT_HANDLE = -10&
Public Const STD_OUTPUT_HANDLE = -11&
Public Const FILE_BEGIN = 0&

' environment variables
'
Public CGI_Accept As String
Public CGI_AuthType As String
Public CGI_ContentLength As String
Public CGI_ContentType As String
Public CGI_GatewayInterface As String
Public CGI_PathInfo As String
Public CGI_PathTranslated As String
Public CGI_QueryString As String
Public CGI_Referer As String
Public CGI_RemoteAddr As String
Public CGI_RemoteHost As String
Public CGI_RemoteIdent As String
Public CGI_RemoteUser As String
Public CGI_RequestMethod As String
Public CGI_ScriptName As String
Public CGI_ServerSoftware As String
Public CGI_ServerName As String
Public CGI_ServerPort As String
Public CGI_ServerProtocol As String
Public CGI_UserAgent As String

Public lContentLength As Long ' CGI_ContentLength converted to Long
Public hStdIn As Long ' handle of Standard Input
Public hStdOut As Long ' handle of Standard Output
Public sErrorDesc As String ' constructed error message
Public sEmail As String ' webmaster's/your email address
Public sFormData As String ' url-encoded data sent by the server

Type pair
Name As String
Value As String
End Type

Public tPair() As pair ' array of name=value pairs

Sub Main()

On Error GoTo ErrorRoutine
InitCgi ' Load environment vars and perform other initialization
GetFormData ' Read data sent by the server
CGI_Main ' Process and return data to server

EndPgm:
End ' end program

ErrorRoutine:
sErrorDesc = Err.Description & ' Error Number = ' & Str$(Err.Number)
ErrorHandler
Resume EndPgm
End Sub

Sub ErrorHandler()
Dim rc As Long

On Error Resume Next

' use SetFilePointer API to reset stdOut to BOF
' and SetEndOfFile to reset EOF

rc = SetFilePointer(hStdOut, 0&, 0&, FILE_BEGIN)

SendHeader 'Internal Error'
Send '<H1>Error in ' & CGI_ScriptName & '</H1>'

Send 'The following internal error has occurred:'
Send '<PRE>' & sErrorDesc & '</PRE>'
Send '<I>Please</I> note what you were doing when this problem occurred, '
Send 'so we can identify and correct it. Write down the Web page you were '
Send 'using, any data you may have entered into a form or search box, '
Send 'and anything else that may help us duplicate the proble delim1 = InStr(pointer, sData, '=')
If delim1 = 0 Then Exit Do
pointer = delim1 + 1
lPairs = lPairs + 1
Loop

If lPairs = 0 Then Exit Sub 'nothing to add

' redim tPair() based on the number of pairs found in sData
ReDim Preserve tPair(lastPair + lPairs) As pair

' assign values to tPair().name and tPair().value
pointer = 1
For n = (lastPair + 1) To UBound(tPair)
delim1 = InStr(pointer, sData, '=') ' find next equal sign
If delim1 = 0 Then Exit For ' parse complete

tPair(n).Name = UrlDecode(Mid$(sData, pointer, delim1 - pointer))

delim2 = InStr(delim1, sData, '&')

' if no trailing ampersand, we are at the end of data
If delim2 = 0 Then delim2 = Len(sData) + 1

' value is between the '=' and the '&'
tPair(n).Value = UrlDecode(Mid$(sData, delim1 + 1, delim2 - delim1 - 1))
pointer = delim2 + 1
Next n
End Sub

Public Function UrlDecode(ByVal sEncoded As String) As String
'========================================================
' Accept url-encoded string
' Return decoded string
'========================================================

Dim pointer As Long ' sEncoded position pointer
Dim pos As Long ' position of InStr target

If sEncoded = '' Then Exit Function

' convert '+' to space
pointer = 1
Do
pos = InStr(pointer, sEncoded, '+')
If pos = 0 Then Exit Do
Mid$(sEncoded, pos, 1) = ' '
pointer = pos + 1
Loop

' convert '%xx' to character
pointer = 1

On Error GoTo errorUrlDecode

Do
pos = InStr(pointer, sEncoded, '%')
If pos = 0 Then Exit Do

Mid$(sEncoded, pos, 1) = Chr$('&H' & (Mid$(sEncoded, pos + 1, 2)))
sEncoded = Left$(sEncoded, pos) _
& Mid$(sEncoded, pos + 3)
pointer = pos + 1
Loop
On Error GoTo 0 'reset error handling
UrlDecode = sEncoded
Exit Function

errorUrlDecode:
'--------------------------------------------------------------------
' If this function was mistakenly called with the following:
' UrlDecode('100% natural')
' a type mismatch error would be raised when trying to convert
' the 2 characters after '%' from hex to character.
' Instead, a more descriptive error message will be generated.
'--------------------------------------------------------------------
If Err.Number = 13 Then 'Type Mismatch error
Err.Clear
Err.Raise 65001, , 'Invalid data passed to UrlDecode() function.'
Else
Err.Raise Err.Number
End If
Resume Next
End Function

Function GetCgiValue(cgiName As String) As String
'=========================================================== =========
' Accept the name of a pair
' Return the value matching the name
'
' tPair(0) is always empty.
' An empty string will be returned
' if cgiName is not defined in the form (programmer error)
' or, a select type form item was used, but no item was selected.
'
' Multiple values, separated by a semi-colon, will be returned
' if the form item uses the 'multiple' option
' and, more than one selection was chosen.
' The calling procedure must parse this string as needed.
'=========================================================== =========
Dim n As Integer

For n = 1 To UBound(tPair)
If UCase$(cgiName) = UCase$(tPair(n).Name) Then
If GetCgiValue = '' Then
GetCgiValue = tPair(n).Value
Else ' allow for multiple selections
GetCgiValue = GetCgiValue & ';' & tPair(n).Value
End If
End If
Next n
End Function

Sub SendHeader(sTitle As String)
Send 'Status: 200 OK'
Send 'Content-type: text/html' & vbCrLf
Send '<HTML><HEAD><TITLE>' & sTitle & '&lt
0 / 0 / 0
Регистрация: 10.04.2007
Сообщений: 96
11.04.2007, 01:51  [ТС] 3
Спасибо. Благодарю.
0
0 / 0 / 3
Регистрация: 27.03.2012
11.04.2007, 12:09 4
Вот еще 3 примера
http://www.tbrown.dircon.co.uk/vb/cgi.htm
0
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
11.04.2007, 12:09

Вычисление значений функции двух переменных в Visual Basic - Visual Basic
Помогите пожалуйста! В среде VB написать программу вычисления значений функции двух переменных....

Где бесплатно скачать учебник по Visual Basic 6 и Visual Basic .Net ?
Где бесплатно скачать учебник по Visual Basic 6 и Visual Basic .Net

Visual Basic 6 и Visual Basic .NET - в чем различия?
Visual Basic и Visual studio это не одно и тоже? если нет то в чём разница, по мимо оформления?

Отличия версий Visual Basic 6.0 от Visual Basic 6.5?
У меня 3 вопроса: 1.Чем отличается версия Visual Basic 6.0 от Visual Basic 6.5? 2.Можно ли...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
4
Ответ Создать тему
Опции темы

КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2022, CyberForum.ru