[vb6] lettura data intera

domenica 15 ottobre 2006 - 16.33

Incantatore Profilo | Newbie

è nato un problema funziona tutto ma si basa solo sul giorno nel senso :

sei io metto

dal 14.10.2006 al 17.10.2006



mi aggiunge anche quelli con data 15.11.2006 quindi calcola solo il giorno e nn da peso ai MESI

come risolvo? ho provato ad usare il LEN(text2.text) ect.. ma facendo cosi non mi funziona più nulla.


aspetto aiuto
grazie


ecco il codice

Dim db As Database
Dim rs As Recordset
Dim WS As Workspace
Dim dbfile As String
Dim pwdstring As String


ListView1.ListItems.Clear


Text2.Text = FormatDate(Text2.Text, dd´mm´yyyy)
Text3.Text = FormatDate(Text3.Text, dd´mm´yyyy)

Set WS = DBEngine.Workspaces(0)
dbfile = (App.Path & "\Data\date.mdb")
pwdstring = "swordfish"
Set db = DBEngine.OpenDatabase(dbfile, False, False, ";PWD=" & pwdstring)
Set rs = db.OpenRecordset("SELECT * FROM pagamenti")


Do While Not rs.EOF
If Not rs.EOF And Not rs.BOF And rs("gennaio") = "0" And rs("gennaio1") >= Text2.Text And rs("gennaio1") <= Text3.Text Or _
Not rs.EOF And Not rs.BOF And rs("febbraio") = 0 And rs("febbraio1") >= Text2.Text And rs("febbraio1") <= Text3.Text Or _
Not rs.EOF And Not rs.BOF And rs("marzo") = 0 And rs("marzo1") >= Text2.Text And rs("marzo1") <= Text3.Text Or _
Not rs.EOF And Not rs.BOF And rs("aprile") = 0 And rs("aprile1") >= Text2.Text And rs("aprile1") <= Text3.Text Or _
Not rs.EOF And Not rs.BOF And rs("maggio") = 0 And rs("maggio1") >= Text2.Text And rs("maggio1") <= Text3.Text Or _
Not rs.EOF And Not rs.BOF And rs("giugno") = 0 And rs("giugno1") >= Text2.Text And rs("giugno1") <= Text3.Text Or _
Not rs.EOF And Not rs.BOF And rs("luglio") = 0 And rs("luglio1") >= Text2.Text And rs("luglio1") <= Text3.Text Or _
Not rs.EOF And Not rs.BOF And rs("agosto") = 0 And rs("agosto1") >= Text2.Text And rs("agosto1") <= Text3.Text Or _
Not rs.EOF And Not rs.BOF And rs("settembre") = 0 And rs("settembre1") >= Text2.Text And rs("settembre1") <= Text3.Text Or _
Not rs.EOF And Not rs.BOF And rs("ottobre") = 0 And rs("ottobre1") >= Text2.Text And rs("ottobre1") <= Text3.Text Or _
Not rs.EOF And Not rs.BOF And rs("novembre") = 0 And rs("novembre1") >= Text2.Text And rs("novembre1") <= Text3.Text Or _
Not rs.EOF And Not rs.BOF And rs("dicembre") = 0 And rs("dicembre1") >= Text2.Text And rs("dicembre1") <= Text3.Text Or _
Not rs.EOF And Not rs.BOF And rs("trimestre") = 0 And rs("trimestre1") >= Text2.Text And rs("trimestre1") <= Text3.Text Or _
Not rs.EOF And Not rs.BOF And rs("semestre") = 0 And rs("semestre1") >= Text2.Text And rs("semestre1") <= Text3.Text Or _
Not rs.EOF And Not rs.BOF And rs("annuale") = 0 And rs("annuale1") >= Text2.Text And rs("annuale1") <= Text3.Text Then


ListView1.ListItems.Add , , rs("nome") , , 1

End If
rs.MoveNext
Loop

Slave Profilo | Junior Member

prova così:

dim data1,data2 as date
data1 = FormatDate(Text2.Text, dd/mm/yyyy)
data2 = FormatDate(Text3.Text, dd/mm/yyyy)

Set WS = DBEngine.Workspaces(0)
dbfile = (App.Path & "\Data\date.mdb")
pwdstring = "swordfish"
Set db = DBEngine.OpenDatabase(dbfile, False, False, ";PWD=" & pwdstring)
Set rs = db.OpenRecordset("SELECT * FROM pagamenti")


Do While Not rs.EOF
If Not rs.EOF And Not rs.BOF And rs("gennaio") = "0" And rs("gennaio1") >= data1 And rs("gennaio1") <= data2Or _
.........


fammi sapere...ciao!
Sono solo uno sballato in un mondo di sballati....

Incantatore Profilo | Newbie

ora funziona cioè quasi si è mezzo problema risolto

se io ho


carlo 11/10/2006
luca 12/11/2006
marco 12/09/2006



io cerco esempio dal 11/10/2006 al 12/10/2006

mi dovrebbe aggiungere solo carlo
prima mi aggiungeva tutti è tre

ora invece mi aggiunge carlo e marco , quindi se il mese è più grande nn me l'aggiunge se è più piccolo si.


come mai?

ciao e grazie tante già mi hai risolto un bel pò ! è diventata na cosa di principio perchè il mese più piccolo me l'aggiunge!!!!

Slave Profilo | Junior Member

mm....hai controllato che il campo del db dia di tipo data,vero???
cmq prova ancora cosi....

Do While Not rs.EOF
If Not rs.EOF And Not rs.BOF And rs("gennaio") = "0" And rs("gennaio1") >= #data1# And rs("gennaio1") <= #data2# Or _

......

in teoria non dovresti avere piu problemi....fammi sapere...ciao!!!
Sono solo uno sballato in un mondo di sballati....

dallas Profilo | Newbie

Scusa, ma mi sembra che questa If che usi sia un po' "eccessiva" ...

Sicuramente si puo' scrivere in maniera piu' breve, utilizzando un paio di if senza ripetere il controllo di eof e bof in quel modo ...

Incantatore Profilo | Newbie

ora funziona tutto , grande!!


grazie tante per l'aiuto e per la pazienza.


p.s lo so che l'if è un pò lungo però funziona bene!

Slave Profilo | Junior Member

ma figurati...siamo qui per questo...
Sono solo uno sballato in un mondo di sballati....
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5