Считывание данных из гостевой книги

Информация - Компьютеры, программирование

Другие материалы по предмету Компьютеры, программирование

p;

txtobj1.SkipLine

strTemp = txtobj1.ReadLine

intFirst = InStr(1, strTemp, ">") + 1

intLen = InStr(InStr(1, strTemp, ">"), strTemp, "<") - intFirst

strCity = Mid(strTemp, intFirst, intLen)

If strCity = "&nbsp;" Then strCity = ""

txtobj1.SkipLine

strTemp = txtobj1.ReadLine

intFirst = InStr(1, strTemp, ">") + 1

intLen = InStr(InStr(1, strTemp, ">"), strTemp, "<") - intFirst

strRegion = Left(Mid(strTemp, intFirst, intLen), 20)

If strRegion = "&nbsp;" Then strRegion = ""

txtobj1.SkipLine

strTemp = txtobj1.ReadLine

intFirst = InStr(1, strTemp, ">") + 1

intLen = InStr(InStr(1, strTemp, ">"), strTemp, "<") - intFirst

strPostalCode = Mid(strTemp, intFirst, intLen)

If strPostalCode = "&nbsp;" Then strPostalCode = ""

txtobj1.SkipLine

strTemp = txtobj1.ReadLine

intFirst = InStr(1, strTemp, ">") + 1

intLen = InStr(InStr(1, strTemp, ">"), strTemp, "<") - intFirst

strCountry = Mid(strTemp, intFirst, intLen)

If strCountry = "&nbsp;" Then strCountry = ""

 

Извлечь Email address ; Использовать как строкe в VBA proc, но это добавляется к таблице как гиперсвязь

 

txtobj1.SkipLine

txtobj1.SkipLine

txtobj1.SkipLine

strTemp = txtobj1.ReadLine

intFirst = InStr(1, strTemp, ">") + 1

intLen = InStr(InStr(1, strTemp, ">"), strTemp, "<") - intFirst

strEmailAddr = Mid(strTemp, intFirst, intLen)

If strEmailAddr = "&nbsp;" Then strEmailAddr = ""

 

Используйте этот набор печати для отладки целей

 

Debug.Print

Debug.Print strFname & " " & strLname

Debug.Print strCname

Debug.Print strSt1

Debug.Print strSt2

Debug.Print strCity & ", "; strRegion & " " & strPostalCode

Debug.Print strCountry

Debug.Print strEmailAddr

 

Добавьте запись, если это имеет допустимый первичный ключ- клавишу

If strFname <> _

"" And strLname "" Then

With rst1

.AddNew

If strFname <> _

"" Then .Fields("FirstName") = strFname

If strLname <> "" Then .Fields("LastName") = strLname

If strCname <> "" Then .Fields("CompanyName") = strCname

If strSt1 <> "" Then .Fields("Address") = strSt1

If strSt2 <> "" Then .Fields("Address1") = strSt2

If strCity <> "" Then .Fields("City") = strCity

If strRegion <> "" Then .Fields("StateOrProvince") = strRegion

If strPostalCode <> "" Then .Fields("PostalCode") = strPostalCode

If strCountry <> "" Then .Fields("Country") = strCountry

If strEmailAddr <> "" Then .Fields("EMailName") = strEmailAddr

.Update

End With

End If

 

MyExit:

Exit Sub

 

MyErrorTrap:

If Err.Number = -2147217887 Then

 

Перехватчик дублирует ключевую ошибку и заменяет запись

 

Set cmd1 = New ADODB.Command

With cmd1

.ActiveConnection = CurrentProject.Connection

.CommandText = "DELETE * " & "FROM tblContacts " & _

"WHERE tblContacts.EMailName " & "= " & strEmailAddr & ""

.CommandType = adCmdText

.Execute

End With

Resume

Else

Debug.Print Err.Number; Err.Description

Resume MyExit

End If

 

End Sub

Function CleanText(strText As String)

 

Замените специальные символы HTML типа &amp; with & и &quot; with "

 

CleanText = Replace(strText, "&amp;", "&")

CleanText = Replace(CleanText, "&quot;", """")

 

End Function

Как описывалось выше этот набор процедур используется в приложении Access, для считывания данных с файла с расширением html. В этом файле хранятся данные о пользователях Гостевой книги.