Ir para conteúdo
Fórum Script Brasil
  • 0

(Resolvido) Formatar width de Tabelas em vbTab?


Rodrigo_Linhas

Pergunta

Olá galera, estou em uma duvida terrivel com um calendario!

Preciso muito formatar a largura e altura das tabelas só que não consigo, afinal não manjo!

Obs Necessito formatar as tabelas onde ficam as datas

Segue o código abaixo:

<%
' ***Begin Function Declaration***
' New and improved GetDaysInMonth implementation.
' Thanks to Florent Renucci for pointing out that I
' could easily use the same method I used for the
' revised GetWeekdayMonthStartsOn function.
Function GetDaysInMonth(iMonth, iYear)
    Dim dTemp
    dTemp = DateAdd("d", -1, DateSerial(iYear, iMonth + 1, 1))
    GetDaysInMonth = Day(dTemp)
End Function

' Previous implementation on GetDaysInMonth
'Function GetDaysInMonth(iMonth, iYear)
'    Select Case iMonth
'        Case 1, 3, 5, 7, 8, 10, 12
'            GetDaysInMonth = 31
'        Case 4, 6, 9, 11
'            GetDaysInMonth = 30
'        Case 2
'            If IsDate("February 29, " & iYear) Then
'                GetDaysInMonth = 29
'            Else
'                GetDaysInMonth = 28
'            End If
'    End Select
'End Function

Function GetWeekdayMonthStartsOn(dAnyDayInTheMonth)
    Dim dTemp
    dTemp = DateAdd("d", -(Day(dAnyDayInTheMonth) - 1), dAnyDayInTheMonth)
    GetWeekdayMonthStartsOn = WeekDay(dTemp)
End Function

Function SubtractOneMonth(dDate)
    SubtractOneMonth = DateAdd("m", -1, dDate)
End Function

Function AddOneMonth(dDate)
    AddOneMonth = DateAdd("m", 1, dDate)
End Function
' ***End Function Declaration***


Dim dDate     ' Date we're displaying calendar for
Dim iDIM      ' Days In Month
Dim iDOW      ' Day Of Week that month starts on
Dim iCurrent  ' Variable we use to hold current day of month as we write table
Dim iPosition ' Variable we use to hold current position in table

' Get selected date.  There are two ways to do this.
' First check if we were passed a full date in RQS("date").
' If so use it, if not look for seperate variables, putting them togeter into a date.
' Lastly check if the date is valid...if not use today
If IsDate(Request.QueryString("date")) Then
    dDate = CDate(Request.QueryString("date"))
Else
    If IsDate(Request.QueryString("day") & "-" & Request.QueryString("month") & "-" & Request.QueryString("year")) Then
        dDate = CDate(Request.QueryString("day") & "-" & Request.QueryString("month") & "-" & Request.QueryString("year"))
    Else
        dDate = Date()
        ' The annoyingly bad solution for those of you running IIS3
        If Len(Request.QueryString("day")) <> 0 Or Len(Request.QueryString("month")) <> 0 Or Len(Request.QueryString("year")) <> 0 Or Len(Request.QueryString("date")) <> 0 Then
            Response.Write "The date you picked was not a valid date.  The calendar was set to today's date.<BR><BR>"
        End If
        ' The elegant solution for those of you running IIS4
        'If Request.QueryString.Count <> 0 Then Response.Write "The date you picked was not a valid date.  The calendar was set to today's date.<BR><BR>"
    End If
End If

'Now we've got the date.  Now get Days in the choosen month and the day of the week it starts on.
iDIM = GetDaysInMonth(Month(dDate), Year(dDate))
iDOW = GetWeekdayMonthStartsOn(dDate)

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Linhas Rodoviárias.com.br</title>


<!-- Outer Table is simply to get the pretty border-->
</head>
<body link="#797E82" vlink="#797E82" alink="#797E82" bgcolor="#F6F3E7" topmargin="0" leftmargin="0">

<div align="center">
<TABLE BORDER=1 CELLSPACING=0 BGCOLOR=#FCFAEA width="200" cellpadding="0" bordercolor="#87785F" height="3" id="table1">
    <TR>
        <TD BGCOLOR=#8EC601 ALIGN="center" COLSPAN=7>
            <TABLE WIDTH=312 BORDER=0 CELLSPACING=0 CELLPADDING=0 id="table2">
                <TR>
                    <TD ALIGN="right">
                    <p align="center"><A HREF="./calendario.asp?date=<%= SubtractOneMonth(dDate) %>">
                    <span style="text-decoration: none">
                    <img border="0" src="http://www.linhasrodoviarias.com.br/diary/IMG/seta.gif" width="9" height="9">
                    <img border="0" src="http://www.linhasrodoviarias.com.br/diary/IMG/seta.gif" width="9" height="9">
                    <img border="0" src="http://www.linhasrodoviarias.com.br/diary/IMG/seta.gif" width="9" height="9"></span></A></TD>
                    
                    <TD ALIGN="center"><FONT COLOR=#FFFFFF><B><%= MonthName(Month(dDate)) & "  " & Year(dDate) %></B></FONT></TD>
                    <TD ALIGN="left">
                    <p align="center"><A HREF="./calendario.asp?date=<%= AddOneMonth(dDate) %>">
                    <span style="text-decoration: none">
                    <img border="0" src="http://www.linhasrodoviarias.com.br/diary/IMG/seta.gif" width="9" height="9">
                    <img border="0" src="http://www.linhasrodoviarias.com.br/diary/IMG/seta.gif" width="9" height="9">
                    <img border="0" src="http://www.linhasrodoviarias.com.br/diary/IMG/seta.gif" width="9" height="9"></span></A></TD>
                </TR>
            </TABLE>
        </TD>
    </TR>
    <TR>
        <TD ALIGN="center" BGCOLOR=#87785F width="20">
        <FONT COLOR=#FFFFFF face="Verdana" size="2"><B>Dom</B><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></FONT></TD>
        <TD ALIGN="center" BGCOLOR=#87785F width="30">
        <b><font face="Verdana" size="2" color="#FFFFFF">Seg</font></b><FONT COLOR=#FFFFFF face="Verdana" size="2"><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></FONT></TD>
        <TD ALIGN="center" BGCOLOR=#87785F width="30">
        <FONT COLOR=#FFFFFF face="Verdana" size="2"><B>Ter</B><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></FONT></TD>
        <TD ALIGN="center" BGCOLOR=#87785F width="30">
        <b><font face="Verdana" size="2" color="#FFFFFF">Qua</font></b><FONT COLOR=#FFFFFF face="Verdana" size="2"><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></FONT></TD>
        <TD ALIGN="center" BGCOLOR=#87785F width="30">
        <b><font face="Verdana" size="2" color="#FFFFFF">Qui</font></b><FONT COLOR=#FFFFFF face="Verdana" size="2"><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></FONT></TD>
        <TD ALIGN="center" BGCOLOR=#87785F width="30">
        <FONT COLOR=#FFFFFF face="Verdana" size="2"><b>Sex</b><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></FONT></TD>
        <TD ALIGN="center" BGCOLOR=#87785F width="30">
        <FONT COLOR=#FFFFFF face="Verdana" size="2"><B>Sáb</B><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></FONT></TD>
    </TR>
<%
' Write spacer cells at beginning of first row if month doesn't start on a Sunday.
If iDOW <> 1 Then
    Response.Write vbTab & "<TR>" & vbCrLf
    iPosition = 1
    Do While iPosition < iDOW
        Response.Write vbTab & vbTab & "<TD> </TD>" & vbCrLf
        iPosition = iPosition + 1
    Loop
End If

' Write days of month in proper day slots
iCurrent = 1
iPosition = iDOW
Do While iCurrent <= iDIM
    ' If we're at the begginning of a row then write TR
    If iPosition = 1 Then
        Response.Write vbTab & "<TR>" & vbCrLf
    End If
    
    ' If the day we're writing is the selected day then highlight it somehow.
    If iCurrent = Day(dDate) Then
        Response.Write vbTab & vbTab & "<TD BGCOLOR=#8EC601><A target=""Registro"" HREF=""http://www.linhasrodoviarias.com.br/edicao/calendario/Banners_list.asp?a=search&value=1&SearchFor=" & iCurrent & "%2F" & Month(dDate) & "%2F" & Year(dDate) & "&SearchOption=Equals&SearchField=Aviso+de+Vencimento""><FONT SIZE=""1""><B>" & iCurrent & "</B></FONT><BR><BR></TD>" & vbCrLf
    Else
        Response.Write vbTab & vbTab & "<TD><A target=""Registro"" HREF=""http://www.linhasrodoviarias.com.br/edicao/calendario/Banners_list.asp?a=search&value=1&SearchFor=" & iCurrent & "%2F" & Month(dDate) & "%2F" & Year(dDate) & "&SearchOption=Equals&SearchField=Aviso+de+Vencimento""><FONT SIZE=""-1"">" & iCurrent & "</FONT></A><BR><BR></TD>" & vbCrLf
    End If
    
    ' If we're at the endof a row then write /TR
    If iPosition = 7 Then
        Response.Write vbTab & "</TR>" & vbCrLf
        iPosition = 0
    End If
    
    ' Increment variables
    iCurrent = iCurrent + 1
    iPosition = iPosition + 1
Loop

' Write spacer cells at end of last row if month doesn't end on a Saturday.
If iPosition <> 1 Then
    Do While iPosition <= 7
        Response.Write vbTab & vbTab & "<TD> </TD>" & vbCrLf
        iPosition = iPosition + 1
    Loop
    Response.Write vbTab & "</TR>" & vbCrLf
End If
%>
</TABLE>
</div>

Esse é o link do calendário! http://www.linhasrodoviarias.com.br/diary/.../calendario.asp

Assim que eu conseguir terminar vou postar aqui esse calendario!

Editado por Rodrigo_Linhas
Link para o comentário
Compartilhar em outros sites

4 respostass a esta questão

Posts Recomendados

  • 0

Apenas dividi a tabela onde você tem o nome dos dias da semana e inseri uma tabela para as datas, que é onde você mencionou "Necessito formatar as tabelas onde ficam as datas", é onde tem o seguinte comentário "<!-- Aqui você formata as todos das datas !-->"

<%
' ***Begin Function Declaration***
' New and improved GetDaysInMonth implementation.
' Thanks to Florent Renucci for pointing out that I
' could easily use the same method I used for the
' revised GetWeekdayMonthStartsOn function.
Function GetDaysInMonth(iMonth, iYear)
    Dim dTemp
    dTemp = DateAdd("d", -1, DateSerial(iYear, iMonth + 1, 1))
    GetDaysInMonth = Day(dTemp)
End Function

' Previous implementation on GetDaysInMonth
'Function GetDaysInMonth(iMonth, iYear)
'    Select Case iMonth
'        Case 1, 3, 5, 7, 8, 10, 12
'            GetDaysInMonth = 31
'        Case 4, 6, 9, 11
'            GetDaysInMonth = 30
'        Case 2
'            If IsDate("February 29, " & iYear) Then
'                GetDaysInMonth = 29
'            Else
'                GetDaysInMonth = 28
'            End If
'    End Select
'End Function

Function GetWeekdayMonthStartsOn(dAnyDayInTheMonth)
    Dim dTemp
    dTemp = DateAdd("d", -(Day(dAnyDayInTheMonth) - 1), dAnyDayInTheMonth)
    GetWeekdayMonthStartsOn = WeekDay(dTemp)
End Function

Function SubtractOneMonth(dDate)
    SubtractOneMonth = DateAdd("m", -1, dDate)
End Function

Function AddOneMonth(dDate)
    AddOneMonth = DateAdd("m", 1, dDate)
End Function
' ***End Function Declaration***


Dim dDate     ' Date we're displaying calendar for
Dim iDIM      ' Days In Month
Dim iDOW      ' Day Of Week that month starts on
Dim iCurrent  ' Variable we use to hold current day of month as we write table
Dim iPosition ' Variable we use to hold current position in table

' Get selected date.  There are two ways to do this.
' First check if we were passed a full date in RQS("date").
' If so use it, if not look for seperate variables, putting them togeter into a date.
' Lastly check if the date is valid...if not use today
If IsDate(Request.QueryString("date")) Then
    dDate = CDate(Request.QueryString("date"))
Else
    If IsDate(Request.QueryString("day") & "-" & Request.QueryString("month") & "-" & Request.QueryString("year")) Then
        dDate = CDate(Request.QueryString("day") & "-" & Request.QueryString("month") & "-" & Request.QueryString("year"))
    Else
        dDate = Date()
        ' The annoyingly bad solution for those of you running IIS3
        If Len(Request.QueryString("day")) <> 0 Or Len(Request.QueryString("month")) <> 0 Or Len(Request.QueryString("year")) <> 0 Or Len(Request.QueryString("date")) <> 0 Then
            Response.Write "The date you picked was not a valid date.  The calendar was set to today's date.<BR><BR>"
        End If
        ' The elegant solution for those of you running IIS4
        'If Request.QueryString.Count <> 0 Then Response.Write "The date you picked was not a valid date.  The calendar was set to today's date.<BR><BR>"
    End If
End If

'Now we've got the date.  Now get Days in the choosen month and the day of the week it starts on.
iDIM = GetDaysInMonth(Month(dDate), Year(dDate))
iDOW = GetWeekdayMonthStartsOn(dDate)

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Linhas Rodoviárias.com.br</title>


<!-- Outer Table is simply to get the pretty border-->
</head>
<body link="#797E82" vlink="#797E82" alink="#797E82" bgcolor="#F6F3E7" topmargin="0" leftmargin="0">

<div align="center">
<TABLE BORDER=1 CELLSPACING=0 BGCOLOR=#FCFAEA width="200" cellpadding="0" bordercolor="#87785F" height="3" id="table1">
    <TR>
        <TD BGCOLOR=#8EC601 ALIGN="center" COLSPAN=7>
            <TABLE WIDTH=312 BORDER=0 CELLSPACING=0 CELLPADDING=0 id="table2">
                <TR>
                    <TD ALIGN="right">
                    <p align="center"><A HREF="./calendario.asp?date=<%= SubtractOneMonth(dDate) %>">
                    <span style="text-decoration: none">
                    <img border="0" src="http://www.linhasrodoviarias.com.br/diary/IMG/seta.gif" width="9" height="9">
                    <img border="0" src="http://www.linhasrodoviarias.com.br/diary/IMG/seta.gif" width="9" height="9">
                    <img border="0" src="http://www.linhasrodoviarias.com.br/diary/IMG/seta.gif" width="9" height="9"></span></A></TD>
                    
                    <TD ALIGN="center"><FONT COLOR=#FFFFFF><B><%= MonthName(Month(dDate)) & "  " & Year(dDate) %></B></FONT></TD>
                    <TD ALIGN="left">
                    <p align="center"><A HREF="./calendario.asp?date=<%= AddOneMonth(dDate) %>">
                    <span style="text-decoration: none">
                    <img border="0" src="http://www.linhasrodoviarias.com.br/diary/IMG/seta.gif" width="9" height="9">
                    <img border="0" src="http://www.linhasrodoviarias.com.br/diary/IMG/seta.gif" width="9" height="9">
                    <img border="0" src="http://www.linhasrodoviarias.com.br/diary/IMG/seta.gif" width="9" height="9"></span></A></TD>
                </TR>
            </TABLE>
        </TD>
    </TR>
    <TR>
        <TD ALIGN="center" BGCOLOR=#87785F width="20">
        <FONT COLOR=#FFFFFF face="Verdana" size="2"><B>Dom</B><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></FONT></TD>
        <TD ALIGN="center" BGCOLOR=#87785F width="30">
        <b><font face="Verdana" size="2" color="#FFFFFF">Seg</font></b><FONT COLOR=#FFFFFF face="Verdana" size="2"><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></FONT></TD>
        <TD ALIGN="center" BGCOLOR=#87785F width="30">
        <FONT COLOR=#FFFFFF face="Verdana" size="2"><B>Ter</B><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></FONT></TD>
        <TD ALIGN="center" BGCOLOR=#87785F width="30">
        <b><font face="Verdana" size="2" color="#FFFFFF">Qua</font></b><FONT COLOR=#FFFFFF face="Verdana" size="2"><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></FONT></TD>
        <TD ALIGN="center" BGCOLOR=#87785F width="30">
        <b><font face="Verdana" size="2" color="#FFFFFF">Qui</font></b><FONT COLOR=#FFFFFF face="Verdana" size="2"><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></FONT></TD>
        <TD ALIGN="center" BGCOLOR=#87785F width="30">
        <FONT COLOR=#FFFFFF face="Verdana" size="2"><b>Sex</b><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></FONT></TD>
        <TD ALIGN="center" BGCOLOR=#87785F width="30">
        <FONT COLOR=#FFFFFF face="Verdana" size="2"><B>Sáb</B><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></FONT></TD>
    </TR>
</TABLE>

<!-- Aqui você formata as todos das datas !-->
<TABLE BORDER=1 CELLSPACING=0 BGCOLOR=#FCFAEA width="436" cellpadding="0" bordercolor="#87785F" height="3" id="table1">
<%
' Write spacer cells at beginning of first row if month doesn't start on a Sunday.
If iDOW <> 1 Then
    Response.Write vbTab & "<TR>" & vbCrLf
    iPosition = 1
    Do While iPosition < iDOW
        Response.Write vbTab & vbTab & "<TD> </TD>" & vbCrLf
        iPosition = iPosition + 1
    Loop
End If

' Write days of month in proper day slots
iCurrent = 1
iPosition = iDOW
Do While iCurrent <= iDIM
    ' If we're at the begginning of a row then write TR
    If iPosition = 1 Then
        Response.Write vbTab & "<TR>" & vbCrLf
    End If
    
    ' If the day we're writing is the selected day then highlight it somehow.
    If iCurrent = Day(dDate) Then
        Response.Write vbTab & vbTab & "<TD BGCOLOR=#8EC601><A target=""Registro"" HREF=""http://www.linhasrodoviarias.com.br/edicao/calendario/Banners_list.asp?a=search&value=1&SearchFor=" & iCurrent & "%2F" & Month(dDate) & "%2F" & Year(dDate) & "&SearchOption=Equals&SearchField=Aviso+de+Vencimento""><FONT SIZE=""1""><B>" & iCurrent & "</B></FONT><BR><BR></TD>" & vbCrLf
    Else
        Response.Write vbTab & vbTab & "<TD><A target=""Registro"" HREF=""http://www.linhasrodoviarias.com.br/edicao/calendario/Banners_list.asp?a=search&value=1&SearchFor=" & iCurrent & "%2F" & Month(dDate) & "%2F" & Year(dDate) & "&SearchOption=Equals&SearchField=Aviso+de+Vencimento""><FONT SIZE=""-1"">" & iCurrent & "</FONT></A><BR><BR></TD>" & vbCrLf
    End If
    
    ' If we're at the endof a row then write /TR
    If iPosition = 7 Then
        Response.Write vbTab & "</TR>" & vbCrLf
        iPosition = 0
    End If
    
    ' Increment variables
    iCurrent = iCurrent + 1
    iPosition = iPosition + 1
Loop

' Write spacer cells at end of last row if month doesn't end on a Saturday.
If iPosition <> 1 Then
    Do While iPosition <= 7
        Response.Write vbTab & vbTab & "<TD> </TD>" & vbCrLf
        iPosition = iPosition + 1
    Loop
    Response.Write vbTab & "</TR>" & vbCrLf
End If
%>
</TABLE>
</div>

Link para o comentário
Compartilhar em outros sites

  • 0

Desde já muito obrigado pela ajuda Jow você me ajudou muito!

olha como esta ficando: http://www.linhasrodoviarias.com.br/diary/.../calendario.asp

Agora só Teve um Probleminha! eu não consigo formatar o tipo de texto das datas e o nem o tamanho height, eu coloco varios números mas não adianta a altura fica na mesma o que será? :(

olha como eu deixei o códio na parte de baixo:

<div align="center">
    <TABLE BORDER="1" CELLSPACING="0" FONT face="Verdana" size="1" BGCOLOR="#FCFAEA" width="217" height="3" cellpadding="0" bordercolor="#87785F" id="table4">
    
<%
' Write spacer cells at beginning of first row if month doesn't start on a Sunday.
If iDOW <> 1 Then
    Response.Write vbTab & "<TR>" & vbCrLf
    iPosition = 1
    Do While iPosition < iDOW
        Response.Write vbTab & vbTab & "<TD> </TD>" & vbCrLf
        iPosition = iPosition + 1
    Loop
End If

' Write days of month in proper day slots
iCurrent = 1
iPosition = iDOW
Do While iCurrent <= iDIM
    ' If we're at the begginning of a row then write TR
    If iPosition = 1 Then
        Response.Write vbTab & "<TR>" & vbCrLf
    End If
    
    ' If the day we're writing is the selected day then highlight it somehow.
    If iCurrent = Day(dDate) Then
        Response.Write vbTab & vbTab & "<TD BGCOLOR=#91FB00><A target=""Registro"" HREF=""search&value=1&SearchFor=" & iCurrent & "%2F" & Month(dDate) & "%2F" & Year(dDate) & "&SearchOption=Equals&SearchField=Aviso+de+Vencimento""><FONT SIZE=""1""><B>" & iCurrent & "</B></FONT><BR><BR></TD>" & vbCrLf
    Else
        Response.Write vbTab & vbTab & "<TD><A target=""Registro"" HREF=""search&value=1&SearchFor=" & iCurrent & "%2F" & Month(dDate) & "%2F" & Year(dDate) & "&SearchOption=Equals&SearchField=Aviso+de+Vencimento""><FONT SIZE=""-1"">" & iCurrent & "</FONT></A><BR><BR></TD>" & vbCrLf
    End If
    
    ' If we're at the endof a row then write /TR
    If iPosition = 7 Then
        Response.Write vbTab & "</TR>" & vbCrLf
        iPosition = 0
    End If
    
    ' Increment variables
    iCurrent = iCurrent + 1
    iPosition = iPosition + 1
Loop

' Write spacer cells at end of last row if month doesn't end on a Saturday.
If iPosition <> 1 Then
    Do While iPosition <= 7
        Response.Write vbTab & vbTab & "<TD> </TD>" & vbCrLf
        iPosition = iPosition + 1
    Loop
    Response.Write vbTab & "</TR>" & vbCrLf
End If
%>

</TABLE></div>

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.


  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,5k
×
×
  • Criar Novo...