VBA/Excel/Access/Word/Language Basics/Conditional Compilation — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 12:46, 26 мая 2010

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