Hej jeg har lært lidt VB og mangler lidt hjælp! :)
hvordan laver jeg sådan så et program søger efter en speciel fil på ens harddrive fx "text.cfg" og bagefter sender til min e-mail konto.. ? det er nemlig sådan så jeg er ansat et sted hvor jeg bliver nød til at bruge sådan et program ellers vil det tage mig dobbelt så lang tid?
ohh ja jeg er bestyrer i en brugs og skal nummere alle varer som kommer ind omorgenen så det ville være lidt nemmere med lidt hjælp fra computeren.. :-)
Private Type FILETIME dwLowDateTime As Long dwHighDateTime As Long End Type
Private 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 * MAX_PATH cAlternate As String * 14 End Type
Private Type FILE_PARAMS bRecurse As Boolean nCount As Long nSearched As Long sFileNameExt As String sFileRoot As String End Type
Private Declare Function FindClose Lib "kernel32" _ (ByVal hFindFile As Long) As Long
Private Declare Function FindFirstFile Lib "kernel32" _ Alias "FindFirstFileA" _ (ByVal lpFileName As String, _ lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindNextFile Lib "kernel32" _ Alias "FindNextFileA" _ (ByVal hFindFile As Long, _ lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Declare Function lstrlen Lib "kernel32" _ Alias "lstrlenW" (ByVal lpString As Long) As Long
Private Declare Function PathMatchSpec Lib "shlwapi" _ Alias "PathMatchSpecW" _ (ByVal pszFileParam As Long, _ ByVal pszSpec As Long) As Long
Private fp As FILE_PARAMS 'holds search parameters
'if a folder, and recurse specified, call 'method again If (WFD.dwFileAttributes And vbDirectory) Then If Asc(WFD.cFileName) <> vbDot Then
If fp.bRecurse Then SearchForFiles sRoot & TrimNull(WFD.cFileName) & vbBackslash End If End If
Else
'must be a file.. If MatchSpec(WFD.cFileName, fp.sFileNameExt) Then fp.nCount = fp.nCount + 1 List1.AddItem sRoot & TrimNull(WFD.cFileName) End If 'If MatchSpec
End If 'If WFD.dwFileAttributes
fp.nSearched = fp.nSearched + 1
Loop While FindNextFile(hFile, WFD)
End If 'If hFile
Call FindClose(hFile)
End Sub
Private Function QualifyPath(sPath As String) As String
If Right$(sPath, 1) <> vbBackslash Then QualifyPath = sPath & vbBackslash Else: QualifyPath = sPath End If
End Function
Private Function TrimNull(startstr As String) As String
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.