Skip to main content

AccessTr.neT


webden aktarılan plakanın harf gurubunu ayırmak

webden aktarılan plakanın harf gurubunu ayırmak

Çözüldü #6
Ortalığı kızıştırayım. Web olayının lideri esrefigit'tir. Img-grin

Soru ile ilgili farklı bir yöntem.
Vba penceresinde boş bir yere aşağıdaki fonksiyonu ekle

Function PlakaBol(veri)
harf1 = Left(veri, 2)
say = Len(veri)
For i = 3 To say
If Not IsNumeric(Mid(veri, i, 1)) Then
sayi1 = sayi1 & Mid(veri, i, 1)
Else
harf2 = harf2 & Mid(veri, i, 1)
End If
Next
PlakaBol = harf1 & " " & sayi1 & " " & harf2
End Function

Komut5'in tıklandığında olayına yazılı kodu aşağıdaki ile değiştir
Private Sub Komut5_Click()
Dim IE As Object
Dim HTML_Body As Object, HTML_Tables As Object, MyTable As Object
Dim HTML_TableRows As Object
Dim RetVal As Variant, X, a As Integer, SATIRSAYISI As Integer
Dim SonPlaka As String


Set IE = Me.WebBrowser1
Set HTML_Body = IE.Document.All
Set HTML_Tables = HTML_Body.tags("Table")
Set MyTable = HTML_Tables(2)

Set HTML_TableRows = MyTable.GetElementsByTagName("td")
For Each MyRow In HTML_TableRows
X = X + 1
Next
SATIRSAYISI = (X - 3) / 9

ReDim sorgu(7, SATIRSAYISI - 1)

X = 0
For X = 0 To SATIRSAYISI - 1
a = 1 + X
sorgu(0, X) = MyTable.Rows(a).Cells(0).innerText
sorgu(1, X) = MyTable.Rows(a).Cells(1).innerText
sorgu(2, X) = MyTable.Rows(a).Cells(2).innerText
sorgu(3, X) = MyTable.Rows(a).Cells(3).innerText
sorgu(4, X) = MyTable.Rows(a).Cells(4).innerText
sorgu(5, X) = MyTable.Rows(a).Cells(5).innerText
sorgu(6, X) = MyTable.Rows(a).Cells(6).innerText
sorgu(7, X) = MyTable.Rows(a).Cells(7).innerText

Next X

Dim rc As DAO.Recordset
Set rc = CurrentDb.OpenRecordset("Tablo1")

X = 0

For X = 0 To SATIRSAYISI - 1

rc.AddNew

SonPlaka = sorgu(1, X)
rc![Tarih] = sorgu(0, X)
rc![Plaka] = PlakaBol(SonPlaka)
rc![Bölge] = sorgu(2, X)
rc![İstasyon] = sorgu(3, X)
rc![GeçişTipi] = sorgu(4, X)
rc![NormalÜcret] = sorgu(5, X)
rc![CezalıÜcret] = sorgu(6, X)
rc![İndirimliÜcret] = sorgu(7, X)

rc.Update
Next X

Set rc = Nothing
Me![Tablo1 alt formu].Requery

GoTo SafeExit:
'ErrHandler:
SafeExit:
Set HTML_Body = Nothing
Set HTML_Tables = Nothing
Set MyTable = Nothing
Set HTML_TableRows = Nothing
Set HTML_TableDivisions = Nothing
Set IE = Nothing
End Sub

Cevapla

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da

Bu Konudaki Yorumlar
Cvp: webden aktarılan plakanın harf gurubunu ayırmak - Yazar: ozanakkaya - 12/01/2012, 23:57