Olá, preciso que as funções abaixo preencham o campo "txtTrabalho" com 365 se for ano normal e 366 se for ano bissexto. Para isso deve pegar a data do campo "txtAte" .O campo com a data é carregado com dados selecionados em outro form; não é digitado e "Text1" deve receber a parte da data que se refere ao ano e o restante da function faz o cálculo. Qual seria um evento para atirar o valor 365 ou 366 corretamente em txtTrabalho???
Sub VerificaBissexto()
Dim data As Date ' Declara variaveis
data = txtAte.Text
Text1.Text = DatePart("yyyy", data)
Bissexto (Text1)
End Sub
Public Function Bissexto(intAno As Integer) As Boolean
'' verifica se um ano é bissexto
Bissexto = False
txtTrabalho.Text = "365"
If intAno Mod 4 = 0 Then
If intAno Mod 100 = 0 Then
If intAno Mod 400 = 0 Then
Bissexto = True
End If
Else
Bissexto = True
End If
txtTrabalho.Text = "366"
End If
End Function
ALAN
Sub VerificaBissexto()
Dim data As Date ' Declara variaveis
data = txtAte.Text
Text1.Text = DatePart("yyyy", data)
Bissexto (Text1)
End Sub
Public Function Bissexto(intAno As Integer) As Boolean
'' verifica se um ano é bissexto
Bissexto = False
txtTrabalho.Text = "365"
If intAno Mod 4 = 0 Then
If intAno Mod 100 = 0 Then
If intAno Mod 400 = 0 Then
Bissexto = True
End If
Else
Bissexto = True
End If
txtTrabalho.Text = "366"
End If
End Function
ALAN