Results 1 to 2 of 2

Thread: comport

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    16

    Thumbs up

    can any one tell me how to configure the comport with V.B.
    I have posted this question several times but no one has replied yet.Can anyone can help me soon because I am working on a project in V.B which requires configuring the com port.I thank anyone who helps me.kindly send me the coding also.

    I want to create a search box in V.B which resembles the one like the find box of our desktop.tell me how to find the files i wish.I thank anyone who helps me.I am sorry to ask for the coding also because I am the person who has just started to work in V.B based projects.

    anyone with the answer can reach me at:[email protected]

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    comport?
    If you want to search for files matching a pattern you can do it using API.
    Code:
    'Find all files matching a pattern using API
    'this is the bas module code
    
    Option Explicit
    
    Public Declare Function FindFirstFile Lib _
    "kernel32.dll" Alias "FindFirstFileA" _
    (ByVal lpFileName As String, _
    lpFindFileData As WIN32_FIND_DATA) As Long
    
    
    Public Declare Function FindNextFile Lib "kernel32.dll" _
    Alias "FindNextFileA" (ByVal hFindFile As Long, _
    lpFindFileData As WIN32_FIND_DATA) As Long
    
    Declare Function FindClose Lib "kernel32.dll" _
    (ByVal hFindFile As Long) As Long
    
    Public Type FILETIME
      dwLowDateTime As Long
      dwHighDateTime As Long
    End Type
    
    Public Type WIN32_FIND_DATA
      dwFileAttributes As Long
      ftCreationTime As FILETIME
      ftLastAccessTime As FILETIME
      ftLastWriteTime As FILETIME
      nFileSizeHigh As Long
      nFileSizeLow As Long
      dwReserved0 As Long
      dwReserved1 As Long
      cFileName As String * 260
      cAlternate As String * 14
    End Type
    '
    '<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    '
    'Find all files matching a pattern using API
    
    'add a listbox List1 and a command button Command1
    'copy and paste this code in the general declarations of the form
    
    Option Explicit
    
    'lpFileName
    
    'The file search string to look for, including the
    'complete path. It can contain the wildcards * or ?.
    
    'lpFindFileData
    
    'Receives identifying information about the first file
    'that matches the search string.
    
    Private Sub Command1_Click()
    
    ' Search for all files that match "C:\MyProgram\user*.*".  Display
    ' the filename of each file that matches the string.
        
        Dim hsearch As Long  ' handle to the file search
        Dim findinfo As WIN32_FIND_DATA  ' receives info about matching files
        Dim success As Long  ' will be 1 if successive searches are successful, 0 if not
        Dim buffer As String ' string buffer to use to process the filename(s)
        Dim retval As Long  ' generic return value
        Dim sWhatString  'what path and pattern to look for
    
    ' Begin a file search:
    'the default is all text files in c:\my documents
        
        sWhatString = InputBox("Enter the path and type of file to search for.", _
        "Enter the path and type of file!", "C:\My Documents\*.txt")
    
        hsearch = FindFirstFile(sWhatString, findinfo)
        
        If hsearch = -1 Then  ' no files match the search string
          List1.AddItem "(No files matched search parameter)"
          End  ' abort program
        End If
    
    ' Display name of each file that matches the search.  Note that the name is displayed, the
    ' next file (if any) is found, and then the loop restarts.  This way the first file
    ' (found above) will also be displayed.
        
        Do  ' begin loop
    
    ' Extract the filename from the fixed-length string:
      
            buffer = Left(findinfo.cFileName, InStr(findinfo.cFileName, vbNullChar) - 1)
            List1.AddItem buffer  ' display this filename
      
    ' Get the next matching file and loop if it exists:
            
            success = FindNextFile(hsearch, findinfo)
        Loop Until success = 0  ' keep looping until no more matching files are found
    
    ' Close the file search handle
    
        retval = FindClose(hsearch)
    
    End Sub

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width