Zum Hauptinhalt gehen



Convert Date to a code


1 Kommentar

  • Avatar
    Peter Thane

    You could add your year codes into an Array and then reference them from there. 

    Something like this would do the job for you:

    Dim YearCode 
    YearCode = Array("A","B","C","D","E","F","G","H","I","J","K")

    Value = "1A"

    Value1 = Month(Format.NamedSubStrings("TheDate").Value)

    Value2 = Format.NamedSubStrings("TheDate").Value

    Value2 = Right(Value2,1)

    Value2 = YearCode(Value2)

    Value = Value1 & Value2


    NOTE: for this I have added a Date field onto my label and made it a Named Data Source which the month and year VB are getting the base date from. You will need to change the array to match the values you want for each year.

    I created my VB as a Multi Line script but if your date comes from a Database or a Data Entry form entry then you would probably be better making this an Event Controlled Script that is processed after the base data is populated on the label (eg OnNewRecord for a database or OnPostPrompt for data entry values)



Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.