Format Befehl funktioniert nicht ?

  • VB6

Es gibt 4 Antworten in diesem Thema. Der letzte Beitrag () ist von Schamash.

    Format Befehl funktioniert nicht ?

    Hallo,


    ich habe eine Zahl (17102013) und das Flexgrid auf meinem Formular erwartet ein String.

    Ich habe es die Zahl dann in ein String convertiert, aber das soll eigentlich ein Datum sein.


    Nun meine Frage.

    Wie kann ich 17102013 in ein String und den String in ein Date convertieren und formatieren ?


    Ich habe es schon folgendermaßen probiert.

    Visual Basic-Quellcode

    1. Bla = Format(LieferDatum$, "DD.MM.YYYY")

    Visual Basic-Quellcode

    1. Hilfsbla = Cstr(Lieferdatum)
    2. Bla = Format(Hilsbla, "DD.MM.YYYY")

    Visual Basic-Quellcode

    1. Bla= Format(Cstr(LieferDatum, "DD.MM.YYYY")



    Hat leider alles nicht funtioniert. Es kommt dann die Fehlermeldung Überlauf
    17102013 ist kein datum
    17.10.2013 ist ein datum
    17.10.2013 00:00:00 ist ein unformatiertes Datum

    so ungefähr sollte das funktionieren

    Visual Basic-Quellcode

    1. Dim test As String = 17102013
    2. Dim datum As String = Format(CDate(test.Substring(0, 2) & "." & test.Substring(2, 2) & "." & test.Substring(4, 4)), "dd.MM.yyyy")
    There is no CLOUD - just other people's computers

    Q: Why do JAVA developers wear glasses?
    A: Because they can't C#

    Daily prayer:
    "Dear Lord, grand me the strength not to kill any stupid people today and please grant me the ability to punch them in the face over standard TCP/IP."
    Oh.

    Ich hab gerade nachgeschaut ... substring gabs noch nicht in VB6 ... ich war mir sicher das ich das damals auch schon verwendet hatte. Na dann bleiben nur die Befehle die Neptun schon geschrieben.

    Aber die Idee kann der TE übernemen ... die Zahlenfolge zerlegen und dann als Datum wieder zusammensetzten.
    There is no CLOUD - just other people's computers

    Q: Why do JAVA developers wear glasses?
    A: Because they can't C#

    Daily prayer:
    "Dear Lord, grand me the strength not to kill any stupid people today and please grant me the ability to punch them in the face over standard TCP/IP."