'**********************************************************************
' Visual Basic 変換スクリプト
' 各変換元列を変換先列に
' コピーします
'**********************************************************************

Function Main()
   
    Dim ls_syear,ls_smonth,ls_sday,ls_sdate
    Dim ls_eyear,ls_emonth,ls_eday,ls_edate
    Dim li_checkyear
    Dim ls_sex
   
    '顧客番号
    DTSDestination("cust_id") = CInt(DTSSource("cust_id")) + 10000
    '名前
    DTSDestination("name") = Trim(DTSSource("cust_lname")) & " " & Trim(DTSSource("cust_fname"))
    '郵便番号
    DTSDestination("zip_code") = Left(Trim(DTSSource("zip_code")),3) & "-" & Right(Trim(DTSSource("zip_code")),4)
    '住所1
    DTSDestination("address1") = DTSSource("state_name") & " " & DTSSource("city")
    '住所2
    DTSDestination("address2") = DTSSource("street")
    '電話番号
    DTSDestination("phone") = DTSSource("phone")
   
    '登録日
    ls_sdate = Trim(DTSSource("start_date"))
    ls_syear = Left(ls_sdate,2)
    ls_smonth = Mid(ls_sdate,3,2)
    ls_sday = Right(ls_sdate,2)
    li_checkyear = Cint(ls_syear)
   
    if (li_checkyear >= 0 and li_checkyear <= 49) then
        ls_sdate = "20" & ls_syear & "/" & ls_smonth & "/" & ls_sday
    else
        ls_sdate = "19" & ls_syear & "/" & ls_smonth & "/" & ls_sday
    end if

    DTSDestination("start_date") = ls_sdate
   
    '終了日
    ls_edate = Trim(DTSSource("end_date"))
    ls_eyear = CStr(CInt(Left(ls_sdate,4)) + 5)
    ls_emonth = Mid(ls_edate,3,2)
    ls_eday = Right(ls_edate,2)
   
    ls_edate = ls_eyear & "/" & ls_emonth & "/" & ls_eday
   
    DTSDestination("end_date") = ls_edate
   
    '性別
    ls_sex = Trim(DTSSource("sex"))
    if ls_sex = 0 then
        DTSDestination("sex") = "M"
    else
        DTSDestination("sex") = "F"
    end if

    Main = DTSTransformStat_OK

End Function