Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » explain me this code please !!
Closed Thread
Old 05-15-2004, 09:53 AM   #1 (permalink)
 
True Techie

Join Date: Jan 2004

Posts: 164

petogaz

Default explain me this code please !!

hi all !!
is there someone could explain me this code please (just tell me what this code is supposed to do. very important plz):

Code:
Sub doSomething(filename As String) 

    Dim exApp As New Excel.Application 
    Dim exWork As Excel.Workbook 
    Dim exSheet As Excel.Worksheet 
    Dim strTmp As String 
    Dim i As Integer 
    Dim ttt As String 
    Dim tmp As String 
    Dim String1 As String 
    Dim VarT As String 
    Dim VarTb As String 
    
    
    
        
    exApp.Visible = True 
    On Error GoTo **** 
    i = InStrRev(filename, "\") 
    ttt = Mid(filename, i + 1, 2) 
    Set exWork = exApp.Workbooks.Open(filename, False, False) 
    Set exSheet = exWork.Sheets(1) 
    For Each exSheet In exWork.Sheets 
        String1 = "" 
        exSheet.Select 
        GoodDate = exSheet.Cells(2, "C") 
        GoodDate = Right(GoodDate, Len(GoodDate) - InStr(GoodDate, "day ") - 3) 
        GoodDate = Format(GoodDate, "YYYY-MM-DD") 
        i = 8 
        While Trim(exSheet.Cells(i, "A")) <> "" 
        
        ScheduleDate = "" 
        BroadCastDate = "" 
        Ttime = "" 
        txtrem = "" 
        Duration = "" 
        Title = "" 
        orig_desc = "" 
        channel_type = "" 
        ct_date_sch = "" 
        canceled = "" 
        video_uk = "" 
        video_eur = "" 
        vps = "" 
        teletex = "" 
        teletex_lan = "" 
        Live = "" 
        Stereo = "" 
        two_tone = "" 
        two_tone_lan = "" 
        subtitle = "" 
        subtitle_lan = "" 
        encryption = "" 
        Language = "" 
        highlight = "" 
        first_showing = "" 
        last_showing = "" 
        repeated_from = "" 
        simulcast = "" 
        pay_per_view = "" 
        is_umbrella = "" 
        channel_rating = "" 
        channel_cat = "" 
        Ori_Title = "" 
        episode_title = "" 
        ori_epi_title = "" 
        Episode_nb = "" 
        Version = "" 
        aka_title = "" 
        actor_list = "" 
        director = "" 
        presenter = "" 
        guests = "" 
        production = "" 
        distribution = "" 
        country = "" 
        Year_of_Prod = "" 
        Emission_duration = "" 
        ori_language = "" 
        black_white = "" 
        colorised = "" 
        categorie = "" 
        Ttype = "" 
        content = "" 
        starrating = "" 
        certification = "" 
        pilot = "" 
        synopsis = "" 
        text_1 = "" 
        text_2 = "" 
        credits = "" 
        Main_actor1 = "" 
        Role_actor1 = "" 
        Main_actor2 = "" 
        Role_actor2 = "" 
        Main_actor3 = "" 
        Role_actor3 = "" 
        Main_actor4 = "" 
        Role_actor4 = "" 
        Main_actor5 = "" 
        Role_actor5 = "" 
        Main_actor6 = "" 
        Role_actor6 = "" 
        Regional = "" 
        Silent = "" 
        Dolby = "" 
        SizeNine = "" 
        sched_extra = "" 
        dumpdate = "" 
        ID = "" 
        moved_id = "" 

        
            'strTmp = strTmp & "pmv" & vbTab & GoodDate & vbTab 
            VarT = exSheet.Cells(i, "A") 
            If i = 8 Then 
                VarT = "0600" 
            End If 
            
            If exSheet.Cells(i + 1, "A") <> "" Then 
                VarTb = exSheet.Cells(i + 1, "A") 
            Else 
                VarTb = "0600" 
            End If 
            If InStr(VarT, ":") <> 0 Then 
                VarT = Replace(VarT, ":", "") 
            End If 
            If InStr(VarTb, ":") <> 0 Then 
                VarTb = Replace(VarTb, ":", "") 
            End If 
            Ttime = Mid(VarT, 1, 2) & ":" & Mid(VarT, 3, 2) 
            Ttimeb = Mid(VarTb, 1, 2) & ":" & Mid(VarTb, 3, 2) 
            
            
            Ttime = Format(DateAdd("h", 1, CDate(Ttime)), "HH:NN") 
            Ttimeb = Format(DateAdd("h", 1, CDate(Ttimeb)), "HH:NN") 
            
            If Ttime < CDate("07:00") And Ttime >= CDate("00:00") Then 
                Broad_Date = Format(DateAdd("d", 1, GoodDate), "yyyy-mm-dd") & " " & Ttime 
            Else 
                Broad_Date = GoodDate & " " & Ttime 
            End If 
            
            Duration = DateDiff("N", Ttime, Ttimeb) 
            If Duration < 0 Then 
                Duration = Duration + 1440 
            End If 
            Ttime = Format(Ttime, "HHNN") 
                        
            Title = exSheet.Cells(i, "B") 
            If InStr(Title, "(") <> 0 Then 
                orig_desc = Right(Title, Len(Title) - InStr(Title, "(") + 1) 
                Title = Left(Title, InStr(Title, " (") - 1) 
            End If 
            If InStr(orig_desc, "Live") <> 0 Then 
                Live = "1" 
            End If 
            If InStr(orig_desc, "(R)") <> 0 Then 
                repeated_from = "01/01/1901" 
            End If 
            If InStr(orig_desc, "'") <> 0 Then 
                Emission_duration = Right(orig_desc, Len(orig_desc) - InStrRev(orig_desc, " ")) 
                Emission_duration = Replace(Emission_duration, "'", "") 
            End If 
            
            Episode_nb = exSheet.Cells(i, "C") 
            synopsis = exSheet.Cells(i, "E") 
            If exSheet.Cells(i, "F") <> "" Then 
                channel_cat = exSheet.Cells(i, "F") 
                If exSheet.Cells(i, "G") <> "" Then 
                    channel_cat = channel_cat & " / " & exSheet.Cells(i, "G") 
                End If 
            End If 
            
            'If exSheet.Cells(i, "C") <> "" Then 
            '    strTmp = strTmp & "Episode Number: " & exSheet.Cells(i, "C") & vbCrLf 
            'End If 
            'If exSheet.Cells(i, "F") <> "" Then 
            '    strTmp = strTmp & "Genre: " & exSheet.Cells(i, "F") & vbCrLf 
            'End If 
            'If exSheet.Cells(i, "G") <> "" Then 
            '    strTmp = strTmp & "Subgenre: " & exSheet.Cells(i, "G") & vbCrLf 
            'End If 
            'strTmp = strTmp & exSheet.Cells(i, "E") & vbCrLf 
            i = i + 1 
            
            String1 = String1 & "pmv" & vbTab & GoodDate & vbTab & Broad_Date & _ 
        vbTab & Ttime & vbTab & txtrem & vbTab & Duration & vbTab & Title & vbTab & _ 
        orig_desc & vbTab & channel_type & vbTab & ct_date_sch & vbTab & canceled & _ 
        vbTab & video_uk & vbTab & video_eur & vbTab & vps & vbTab & teletex & _ 
        vbTab & teletex_lan & vbTab & Live & vbTab & Stereo & vbTab & two_tone & _ 
        vbTab & two_tone_lan & vbTab & subtitle & vbTab & subtitle_lan & vbTab & _ 
        encryption & vbTab & Language & vbTab & highlight & vbTab & first_showing & _ 
        vbTab & last_showing & vbTab & repeated_from & vbTab & simulcast & vbTab & _ 
        pay_per_view & vbTab & is_umbrella & vbTab & channel_rating & vbTab & channel_cat & _ 
        vbTab & Ori_Title & vbTab & episode_title & vbTab & ori_epi_title & vbTab & _ 
        Episode_nb & vbTab & Version & vbTab & aka_title & vbTab & actor_list & vbTab & _ 
        director & vbTab & presenter & vbTab & guests & vbTab & production & vbTab & _ 
        distribution & vbTab & country & vbTab & Year_of_Prod & vbTab & _ 
        Emission_duration & vbTab & ori_language & vbTab & black_white & vbTab & _ 
        colorised & vbTab & categorie & vbTab & Ttype & vbTab & content & vbTab & _ 
        starrating & vbTab & certification & vbTab & pilot & vbTab & synopsis & _ 
        vbTab & text_1 & vbTab & text_2 & vbTab & credits & vbTab & Main_actor1 & _ 
        vbTab & Role_actor1 & vbTab & Main_actor2 & vbTab & Role_actor2 & vbTab & _ 
        Main_actor3 & vbTab & Role_actor3 & vbTab & Main_actor4 & vbTab & _ 
        Role_actor4 & vbTab & Main_actor5 & vbTab & Role_actor5 & vbTab & _ 
        Main_actor6 & vbTab & Role_actor6 & vbTab & Regional & vbTab & Silent & _ 
        vbTab & Dolby & vbTab & SizeNine & vbTab & sched_extra & vbTab & dumpdate & _ 
        vbTab & ID & vbTab & moved_id & vbCrLf 
          
        Wend 
        PrintOut String1, filename & ".txt" 
        
    Next 
    exWork.Close False 
    exApp.Quit 
    Set exApp = Nothing 
    Exit Sub 
****: 
    MsgBox "error : " & Err.Number & ", " & Err.Description & ", " & Err.Source 
    exApp.Quit 
    Set exApp = Nothing 
End Sub 

Private Sub CmdDo_Click() 
    Dim i As Integer 
    For i = 0 To File1.ListCount - 1 
        If File1.Selected(i) Then doSomething File1.Path & "\" & File1.List(i) 
    Next 
End Sub 

Private Sub CmdExit_Click() 
    Unload Me 
End Sub 

Private Sub Dir1_Change() 
    File1.Path = Dir1.Path 
End Sub 

Private Sub Drive1_Change() 
    On Error GoTo **** 
    Dir1.Path = Drive1 
    File1.Path = Dir1.Path 
****: 
    If Err.Number = 68 Then MsgBox "Drives unavailable." 
    Err.Clear 
End Sub 

Private Sub PrintOut(str As String, filename As String) 
    Open filename For Append Shared As #1 
    Print #1, str 
    Close #1 
End Sub

__________________
\"you cant hold a good techie down\"
petogaz is offline  
Old 05-16-2004, 10:14 AM   #2 (permalink)
 
Banned

Join Date: Jan 2004

Posts: 471

subdivizion

Default

it looks like it's entering movie information from an Excel file to a text file using a lot of formatting and error-checking. can someone else elaborate?
subdivizion is offline  
Old 05-17-2004, 02:07 PM   #3 (permalink)
 
True Techie

Join Date: Jan 2004

Posts: 164

petogaz

Default

come on guyz !!!
anyone else ?
__________________
\"you cant hold a good techie down\"
petogaz is offline  
Old 05-17-2004, 03:01 PM   #4 (permalink)
 
Banned

Join Date: May 2003

Posts: 105

imported_Jack

Default

Have you taken the code and pasted into a project and tried to run it?

A few lines of code is one thing but I do nto have the free time to walk through you block above and document it.
imported_Jack is offline  
Old 08-13-2004, 01:14 PM   #5 (permalink)
 
Banned

Join Date: Aug 2004

Posts: 50

gecko_au2003

Default

do you want it explaining line by line or what ? Also why dont you just try it out and see what happens when you try to use the code? That way you will see what happens when you try it out !
gecko_au2003 is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On