home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_2 / X_TAL4 / DEMODLL2.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-08-28  |  4.7 KB  |  152 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. Option Explicit
  64. Sub Command1_Click ()
  65.     Dim saveErr As Integer
  66.     Dim Filename As String
  67.     Dim Filetitle As String
  68.     Dim p As Integer
  69.     Dim reportPath As String
  70.     Dim errcode As Integer
  71.     Dim allReports As String
  72.     Dim nextFileTitle As String
  73.     Dim reportTitle As String
  74.     Dim reportComment As String
  75.     Dim reportTitleTemp As String
  76.     Dim reportCommentTemp As String
  77.     cmdialog1.DialogTitle = "Select Report Directory"
  78.     cmdialog1.Filename = ""
  79.     cmdialog1.Filter = "Reports (*.rpt) | *.rpt "
  80.     cmdialog1.FilterIndex = 1
  81.     cmdialog1.Flags = OFN_PATHMUSTEXIST Or OFN_READONLY
  82.     On Error Resume Next
  83.         cmdialog1.Action = DLG_FILE_OPEN
  84.         saveErr = Err
  85.     On Error GoTo 0
  86.     If saveErr <> 0 Then Exit Sub
  87.     mousepointer = 11
  88.     lstTitles.Clear
  89.     lstComments.Clear
  90.     lblComment.Caption = ""
  91.     Filename = cmdialog1.Filename
  92.     Filetitle = cmdialog1.Filetitle
  93.     p = InStr(Filename, Filetitle)
  94.     reportPath = Left$(Filename, p - 1)
  95.     If Right$(reportPath, 1) <> "\" Then
  96.        reportPath = reportPath & "\"
  97.     End If
  98.     allReports = reportPath + "*.rpt"
  99.     reportTitle = Space$(512) 'Maximum 512. No terminating null character.
  100.     reportComment = Space$(1024)  'Maximum 1024. No terminating null character.
  101.     nextFileTitle = Dir(allReports)
  102.     While Len(nextFileTitle)
  103.         GetreportTitle reportPath & nextFileTitle, reportTitle, reportComment, errcode
  104.         If errcode <> 0 Then
  105.            MsgBox "Error code:" & Str$(errcode)
  106.         End If
  107.         
  108.         'Note: no terminating null character to check:
  109.         reportTitleTemp = Trim$(reportTitle)
  110.         reportCommentTemp = Trim$(reportComment)
  111.         If errcode = 0 Then
  112.            If Len(reportTitleTemp) Then
  113.               lstTitles.AddItem nextFileTitle & "  :  " & reportTitleTemp
  114.            Else
  115.               lstTitles.AddItem nextFileTitle & "  :  No Description"
  116.            End If
  117.            If Len(reportCommentTemp) Then
  118.               lstComments.AddItem reportCommentTemp
  119.            Else
  120.               lstComments.AddItem "No Comment."
  121.            End If
  122.         End If
  123.         nextFileTitle = Dir
  124.         
  125.     Wend
  126.     mousepointer = 0
  127. End Sub
  128. Sub lstTitles_Click ()
  129. ShowComment
  130. End Sub
  131. Sub lstTitles_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  132. If Button = 1 Then
  133.    ShowComment
  134. End If
  135. End Sub
  136. Sub lstTitles_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  137. If Button = 1 Then
  138.    ShowComment
  139. End If
  140. End Sub
  141. Sub ShowComment ()
  142.          
  143.          Dim comment As String
  144.          If lstTitles.ListIndex <> -1 Then
  145.             comment = lstComments.List(lstTitles.ListIndex)
  146.             If comment <> lblComment.Caption Then
  147.                 lblComment.Caption = comment
  148.                 lblComment.Refresh
  149.             End If
  150.          End If
  151. End Sub
  152.