home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code2 / x_tal4 / demodll2.frm < prev    next >
Text File  |  1993-08-28  |  5KB  |  171 lines

  1. VERSION 2.00
  2. Begin Form frmReadDescriptions 
  3.    AutoRedraw      =   -1  'True
  4.    Caption         =   "Read Report Descriptions"
  5.    ClientHeight    =   3960
  6.    ClientLeft      =   495
  7.    ClientTop       =   1080
  8.    ClientWidth     =   7365
  9.    Height          =   4365
  10.    Left            =   435
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   3960
  13.    ScaleWidth      =   7365
  14.    Top             =   735
  15.    Width           =   7485
  16.    Begin ListBox lstComments 
  17.       Height          =   420
  18.       Left            =   765
  19.       TabIndex        =   2
  20.       Top             =   3900
  21.       Visible         =   0   'False
  22.       Width           =   1785
  23.    End
  24.    Begin CommonDialog CMDialog1 
  25.       CancelError     =   -1  'True
  26.       DialogTitle     =   "Select Directory"
  27.       Left            =   165
  28.       Top             =   3900
  29.    End
  30.    Begin ListBox lstTitles 
  31.       Height          =   2175
  32.       Left            =   90
  33.       TabIndex        =   1
  34.       Top             =   690
  35.       Width           =   7125
  36.    End
  37.    Begin CommandButton Command1 
  38.       Caption         =   "Select Report Directory..."
  39.       Height          =   360
  40.       Left            =   105
  41.       TabIndex        =   0
  42.       Top             =   105
  43.       Width           =   2400
  44.    End
  45.    Begin Label Label1 
  46.       Caption         =   "Comment for item selected:"
  47.       Height          =   480
  48.       Left            =   210
  49.       TabIndex        =   4
  50.       Top             =   3060
  51.       Width           =   1200
  52.       WordWrap        =   -1  'True
  53.    End
  54.    Begin Label lblComment 
  55.       BorderStyle     =   1  'Fixed Single
  56.       Height          =   720
  57.       Left            =   1560
  58.       TabIndex        =   3
  59.       Top             =   3045
  60.       Width           =   5670
  61.       WordWrap        =   -1  'True
  62.    End
  63. End
  64. Option Explicit
  65.  
  66. Sub Command1_Click ()
  67.  
  68.     Dim saveErr As Integer
  69.     Dim Filename As String
  70.     Dim Filetitle As String
  71.     Dim p As Integer
  72.     Dim reportPath As String
  73.     Dim errcode As Integer
  74.     Dim allReports As String
  75.     Dim nextFileTitle As String
  76.     Dim reportTitle As String
  77.     Dim reportComment As String
  78.     Dim reportTitleTemp As String
  79.     Dim reportCommentTemp As String
  80.  
  81.     cmdialog1.DialogTitle = "Select Report Directory"
  82.     cmdialog1.Filename = ""
  83.     cmdialog1.Filter = "Reports (*.rpt) | *.rpt "
  84.     cmdialog1.FilterIndex = 1
  85.     cmdialog1.Flags = OFN_PATHMUSTEXIST Or OFN_READONLY
  86.     On Error Resume Next
  87.         cmdialog1.Action = DLG_FILE_OPEN
  88.         saveErr = Err
  89.     On Error GoTo 0
  90.     If saveErr <> 0 Then Exit Sub
  91.     
  92.     mousepointer = 11
  93.     lstTitles.Clear
  94.     lstComments.Clear
  95.     lblComment.Caption = ""
  96.  
  97.     Filename = cmdialog1.Filename
  98.     Filetitle = cmdialog1.Filetitle
  99.     p = InStr(Filename, Filetitle)
  100.     reportPath = Left$(Filename, p - 1)
  101.     If Right$(reportPath, 1) <> "\" Then
  102.        reportPath = reportPath & "\"
  103.     End If
  104.     
  105.     allReports = reportPath + "*.rpt"
  106.     reportTitle = Space$(512) 'Maximum 512. No terminating null character.
  107.     reportComment = Space$(1024)  'Maximum 1024. No terminating null character.
  108.     
  109.     nextFileTitle = Dir(allReports)
  110.     While Len(nextFileTitle)
  111.         GetreportTitle reportPath & nextFileTitle, reportTitle, reportComment, errcode
  112.         If errcode <> 0 Then
  113.            MsgBox "Error code:" & Str$(errcode)
  114.         End If
  115.         
  116.         'Note: no terminating null character to check:
  117.         reportTitleTemp = Trim$(reportTitle)
  118.         reportCommentTemp = Trim$(reportComment)
  119.  
  120.         If errcode = 0 Then
  121.            If Len(reportTitleTemp) Then
  122.               lstTitles.AddItem nextFileTitle & "  :  " & reportTitleTemp
  123.            Else
  124.               lstTitles.AddItem nextFileTitle & "  :  No Description"
  125.            End If
  126.  
  127.            If Len(reportCommentTemp) Then
  128.               lstComments.AddItem reportCommentTemp
  129.            Else
  130.               lstComments.AddItem "No Comment."
  131.            End If
  132.         End If
  133.         nextFileTitle = Dir
  134.         
  135.     Wend
  136.     mousepointer = 0
  137.  
  138. End Sub
  139.  
  140. Sub lstTitles_Click ()
  141. ShowComment
  142. End Sub
  143.  
  144. Sub lstTitles_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  145. If Button = 1 Then
  146.    ShowComment
  147. End If
  148.  
  149. End Sub
  150.  
  151. Sub lstTitles_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  152. If Button = 1 Then
  153.    ShowComment
  154. End If
  155.  
  156. End Sub
  157.  
  158. Sub ShowComment ()
  159.          
  160.          Dim comment As String
  161.          If lstTitles.ListIndex <> -1 Then
  162.             comment = lstComments.List(lstTitles.ListIndex)
  163.             If comment <> lblComment.Caption Then
  164.                 lblComment.Caption = comment
  165.                 lblComment.Refresh
  166.             End If
  167.          End If
  168.  
  169. End Sub
  170.  
  171.