VBA/Excel/Access/Word/Language Basics/Conditional Compilation

Материал из VB Эксперт
Версия от 12:46, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Using Conditional Compilation

 
#Const verSpanish = True
Sub WhatDay()
    Dim dayNr As Integer
    #If verSpanish = True Then
        dayNr = Weekday(InputBox("Entre la fecha, por ejemplo 01/01/2001"))
        MsgBox "Sera " & DayOfWeek(dayNr) & "."
    #Else
        WeekdayName
    #End If
End Sub
Function DayOfWeek(dayNr As Integer) As String
    DayOfWeek = Choose(dayNr, "Domingo", "Lunes", "Martes", _
        "Miercoles", "Jueves", "Viernes", "Sabado")
End Function
Function WeekdayName() As String
    Select Case Weekday(InputBox("Enter date, e.g., 01/01/2000"))
        Case 1
            WeekdayName = "Sunday"
        Case 2
            WeekdayName = "Monday"
        Case 3
            WeekdayName = "Tuesday"
        Case 4
            WeekdayName = "Wednesday"
        Case 5
            WeekdayName = "Thursday"
        Case 6
            WeekdayName = "Friday"
        Case 7
            WeekdayName = "Saturday"
    End Select
    MsgBox "It will be " & WeekdayName & "."
End Function

Option Compare Database
Sub getCurrentPath()
MsgBox CurrentProject.Path
End Sub