VISUAL BASIC

VISUAL BASIC

Από {dora.san}

ΘΕΛΩ ΣΕ ΜΙΑ ΦΟΡΜΑ ΤΗΣ V.B ΝΑ ΕΜΦΑΝΙΖΕΤΑΙ ΣΕ ΜΟΡΦΗ STRING Η ΗΜΕΡΟΜΗΝΙΑ. ΞΕΡΕΙ ΚΑΝΕΙΣ ΠΩΣ ΓΙΝΕΤΑΙ?

  1. 16/6/2004

    πού θέλεις να σου εμφανίζεται;
    γενικά πάντως: CStr(Date)

  1. 16/6/2004

    θελω να
    κανω συνάρτηση στη Visual Basic που να επιστρέφει σε μορφή string την ημερομηνία της τελευταίας μέρας του τρέχοντος μήνα.

  1. 17/6/2004

    try this:


    Option Explicit
    Private Sub Command1_Click()
    'edw kaleis th synarthsh: true gia long date, tipota h false gia short
    MsgBox lastDayofCurrentMonth(True), vbInformation
    End Sub

    Function lastDayofCurrentMonth(Optional ByVal LongDate As Boolean) As String

    Dim intDay
    Dim intMonth
    Dim intYear
    Dim intLastDay

    intYear = CInt(Year(FormatDateTime(Now, vbShortDate)))
    intMonth = CInt(Month(FormatDateTime(Now, vbShortDate)))
    intDay = CInt(Day(FormatDateTime(Now, vbShortDate)))

    lastDayofCurrentMonth = intDay & "/" & intMonth & "/" & intYear

    If intMonth <> 2 Then
    If IsDate("31/" & intMonth & "/" & intYear) Then intLastDay = 31
    If IsDate("30/" & intMonth & "/" & intYear) Then intLastDay = 30
    Else
    If IsDate("29/" & intMonth & "/" & intYear) Then intLastDay = 29
    If IsDate("28/" & intMonth & "/" & intYear) Then intLastDay = 28
    End If

    lastDayofCurrentMonth = intLastDay & "/" & intMonth & "/" & intYear

    If LongDate = True Then
    lastDayofCurrentMonth = CStr(FormatDateTime(CDate(lastDayofCurrentMonth), vbLongDate))
    Else
    lastDayofCurrentMonth = CStr(FormatDateTime(CDate(lastDayofCurrentMonth), vbShortDate))
    End If

    End Function

  1. 17/6/2004

    Διόρθωση:

    Άλλαξε τη σειρά στις γραμμές και κάνε τις έτσι:

    If intMonth <> 2 Then
    If IsDate("30/" & intMonth & "/" & intYear) Then intLastDay = 30
    If IsDate("31/" & intMonth & "/" & intYear) Then intLastDay = 31
    Else
    If IsDate("28/" & intMonth & "/" & intYear) Then intLastDay = 28
    If IsDate("29/" & intMonth & "/" & intYear) Then intLastDay = 29
    End If

    διαφορετικά όλοι οι μήνες θα βγαίνουν με 30 μέρες και ο Φλεβάρης με 28. :o)

  1. 18/6/2004

    παλι την τελευταια ημερα μου την βγαζει σαν π.χ 30/6/2004
    εγω θελω τεταρτη 30 ιουνιου 2004

  1. 18/6/2004

    σε ευχαριστω

  1. 18/6/2004

    Format("enter date", "dd mmmm yyyy")
    πχ
    Format("30/6/2004", "dd mmmm yyyy")

    παντως δεν ησουν σαφης :-)
    κοίτα τί ρώτησες στην αρχή και τί θέλεις τελικά :-)
    no offence !




   Πίσω στην προηγούμενη σελίδα