Recursive File List Function
I have a function that will return any files in a given folder. But in order to make it also return files in subfolders, i was told i would have to make it recursive. Recursive functions are something ive never had to use yet...and quite frankly i dont understand them. Could someone tell me what modifications i would have to make to this function to make it return subfolder files as well?
VB Code: Function DirList(strDir As String) As String() 'returns a 0 based array with the files in strDir 'Can contain a pattern such as "*.*" Dim Count As Integer Dim sFiles() As String Dim sFile As String sFile = Dir$(strDir) Count = -1 Do Count = Count + 1 ReDim Preserve sFiles(Count) sFiles(Count) = sFile sFile = Dir$ Loop DirList = sFilesEnd Function
thanks, Nishant
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Search File In Folder An Recursive Folder With Dir Function
Hi,
I want to search ActiveX .dll in a expecific folder and in all his recursive folders.
I´ve made a recursive function using dir statement. But dir returns error when it finish in one folder and I want that dir function search in the recursive folders too.
This is my code:
Private Sub search(sFolder As String)
Dim sName As String
sName = Dir(sFolder & "", vbDirectory) ' Retrieve the first entry.
Do While sName <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If sName <> "." And sName <> ".." Then
' Use bitwise comparison to make sure sName is a directory.
If (GetAttr(sFolder & "" & sName) And vbDirectory) = vbDirectory Then
' sName is a directory.
Debug.Print sFolder & "" & sName ' Display entry only if it
search sFolder & "" & sName
ElseIf LCase$(Right$(sName, 3)) = "dll" Then
' sNAme is a ActiveX.dll
Debug.Print sFolder & "" & sName
End If
End If
sName = Dir ' Get next entry. <= Here happens an error when the function end searching in 1 recursive folder
Debug.Print sName
Loop
End Sub
What can I do????
Thanks and regards
Tel
Ackerman Function - Recursive Function Help Needed
I recently had to write the following function in maple known as the Ackerman function. However I need to write a function in VBA to calculate it.
The function in maple was the following.
a:=proc(n,m)
if n=0 then RETURN(m+1) fi;
if m=0 then RETURN(a(n-1,1)) fi;
RETURN(a(n-1,a(n,m-1)));
end;
The problem I am having is getting the function to stop iterating. It wont calculate a result even for simple results like T(1,1).
The code I have written in VB is as follows.
Function T(n As Integer, m As Integer)
If m = 0 Then
T(n, m) = T(n - 1, 1)
End If
If n = 0 Then
T(n, m) = m + 1
End If
T(n, m) = T(n - 1, T(n, m - 1))
End Function
Any Ideas? Is it possible
Cheers
Rich
Recursive Function
ok i need to create a recursive fuction that goes through an aray of 25 and finds the highest vallue, help?
Recursive Function
I am trying to write a simple recursive function in Visual Studio Express 2005. Any help would be greatly appriciated:
I am receiving the following error when I try to execute the below code:
Error: 61837 - Unable to write read-only property.
VB Code:
Public Function RemoveUserFromUserClasses(ByRef objUserClass As Object, ByRef objUser As Object) As Boolean On Error GoTo Err_RemoveUserFromUserClasses 'Counter Dim I As Long 'Hold the current User Class Dim objCurUserClass As Object ' For each UserClass remove the user. If objUserClass.Count > 0 Then For I = 1 To objUserClass.Count objCurUserClass = objUserClass.Item(I) objCurUserClass.Users.Remove(objUser) RemoveUserFromUserClasses(objCurUserClass.UserClasses, objUser) Next I End If Exit_RemoveUserFromUserClasses: Exit Function Err_RemoveUserFromUserClasses: If fLogFileOpen Then PrintLine(intLogFileNumber, Str(Now.ToOADate) & ": * * * RemoveUserFromUserClasses Error: " & Err.Number & " - " & Err.Description) End If Resume Exit_RemoveUserFromUserClasses End Function
Edit: Added [vbcode][/vbcode] tags for more clarity. - Hack
Recursive Function Help
Last night I spent forever trying to figure out how to do this. Could somebody tell me how to get started, maybe provide some example code?
Thanks
Recursive Function
Urgent!! I wrote a recursive function. This recursive function will start when I click on the 'Start' button. I need to stop this recursive function when I click on the 'Stop' button, but the 'Stop' button only responce after the recursive function finish, how can I always listen to the 'Stop' button event so I can terminate the recursive function any time as I want? Thanks.
Recursive Function
here is what am trying to do
let say i have a directory called
c:ARTISTS
thats the root
in that directory there is let say 30 different artits
and in those artists SOME can have more than one album
those that dont have more than one album
the songs are located in just the name of the artist
so if artst1 had one album
all the songs would be located in c:Artistsartist1
and if artist2 had 2 albums
it would be like
c:artistsartist2album1 (songs for this album go here)
c:artistsartist2album2 (songs for album2 go here)
so i would like someone to help me out with making a function that when given c:artist
it will go into every directory
and copy artist name(directory), album name( sub directory), and song names (filenames)
into a table..
thank you
Recursive VB Function?
Hi all,
I am looking for a recursive function to step through a tree like structure. What make this difficult is that each child node in the tree only knows if it has a child. It does not know about its parent. My problem is that I can recurse through the tree, moveing to each child nodes child, but I can not return to the previous levels. I do not know how many level deep I need to go, so it must be recursive.
Below is a typical tree structure I will need to recurse. I start at A, then I can get to ABC1. But how to I return to AB1 and continue the process? As you can see, the tree can be many levels deep and I only know if the node has a child and how to get to that child.
A
l
A1------->A1.1
l l
A2 AB1-------->AB1.1
l l l
A3 l ABC1
l AB2----------------------->AB2.1
A4 l l
l AB3 D1---------------->D1.1
A5 l l
l D2 F1
A6------->A6.1 l
l F2
B1---------->B1.1----------->C1
l l
B2.1 C2
l
B3.1
Thanks
Edited by - skyodyssey on 7/30/2004 12:12:31 PM
Problem With Recursive Function
Hi
I have a problem with the following code:
VB Code:
Private scanData() As String Private Sub Form_Load()List1.AddItem "c:My Documents"List1.AddItem "e:"End Sub Private Sub Command1_Click()scanfolders3End Sub Public Sub scanfolders3()Dim startTime, elapTime As DoubleDim startFolder As StringDim scanResult As BooleanscanResult = FalseForm1.MousePointer = vbHourglassstartTime = CDbl(Timer)ReDim scanData(4, 0)startFolder = List1.TextscanResult = scanFolders(startFolder)elapTime = CDbl(Timer) - startTimeForm1.MousePointer = vbNormalText1.Text = elapTimeEnd Sub Public Function scanFolders(fpath As String) As BooleanDim x As DoubleSet fso = CreateObject("Scripting.FileSystemObject") For Each fl In fso.GetFolder(fpath).Files x = UBound(scanData, 2) + 1 ReDim Preserve scanData(4, x) scanData(0, x) = fl.Name scanData(1, x) = fpath scanData(2, x) = fl.Size scanData(3, x) = fl.Type DoEvents x = x + 1 Next fl For Each fldr In fso.GetFolder(fpath).SubFolders scanFolders fldr.Path Next fldrSet fso = NothingSet fldr = NothingSet fl = NothingscanFolders = TrueEnd Function
The main aim of the code is to populate an array with the details of files in a given directory. The form has been added to assess the performance for various drives/directories.
The problem is that subsequent runs of the code take relatively longer each time. Given that "e:" is a 512mb pendrive with about 300mb used and that "c:My Documents" contains about 4GB typical results with times in seconds are:
e: 4.56
e: 4.63
e: 4.45
c:My Documents 17.68
e: 18.11
c:My Documents 86.45
e: 77.5
I can't see where the resources are leaking or what is causing this build up after the larger directory is scanned.
Things I've tried are:
1. Not using Preserve - although this wouldn't work as needed anyway it was no quicker.
2. Commenting out DoEvents - Didn't help
Any ideas?
Thanks
Mouse
Making A Recursive Function
Hi, I need help making a recursive function for the code listed
below.
I posted here previously for solution to listing all subkeys
and values of a registry key. I got the code to do it, but
it only lists on level, so it needs to be put in a recursive
function in order to go through the entire branch.
I've tried to do this but I never worked with recursion before
and I can't get it to work.
I just need to add all the keys and values to a list in this
format:
Key
if it is a key or if it is a value:
Key,value=data
This code does that all but only one step. Can someone
help me with this, it is a one minute job for someone who
worked with recursion before. Thanks in advance.
VB Code:
Const ERROR_NO_MORE_ITEMS = 259&Const HKEY_CURRENT_CONFIG = &H80000005Const HKEY_LOCAL_MACHINE = &H80000002Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As LongPrivate Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As LongPrivate Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As String, lpcbClass As Long, lpftLastWriteTime As Any) As LongPrivate Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As LongPrivate Sub Form_Load() Dim hKey As Long, Cnt As Long, sName As String, sData As String, Ret As Long, RetData As Long Const BUFFER_SIZE As Long = 255 'Set the forms graphics mode to persistent Me.AutoRedraw = True Me.Print "RegEnumKeyEx" Ret = BUFFER_SIZE 'Open the registry key If RegOpenKey(HKEY_LOCAL_MACHINE, "Hardware", hKey) = 0 Then 'Create a buffer sName = Space(BUFFER_SIZE) 'Enumerate the keys While RegEnumKeyEx(hKey, Cnt, sName, Ret, ByVal 0&, vbNullString, ByVal 0&, ByVal 0& ) <> ERROR_NO_MORE_ITEMS 'Show the enumerated key Me.Print " " + Left$(sName, Ret) 'prepare for the next key Cnt = Cnt + 1 sName = Space(BUFFER_SIZE) Ret = BUFFER_SIZE Wend 'close the registry key RegCloseKey hKey Else Me.Print " Error while calling RegOpenKey" End If 'This part below lists the values and their data of selected key Me.Print vbCrLf + "RegEnumValue" Cnt = 0 'Open a registry key If RegOpenKey(HKEY_LOCAL_MACHINE, "SoftwareMicrosoftWindowsCurrentVersion", hKey) = 0 Then 'initialize sName = Space(BUFFER_SIZE) sData = Space(BUFFER_SIZE) Ret = BUFFER_SIZE RetData = BUFFER_SIZE 'enumerate the values While RegEnumValue(hKey, Cnt, sName, Ret, 0, ByVal 0&, ByVal sData, RetData) <> ERROR_NO_MORE_ITEMS 'show data If RetData > 0 Then Me.Print " " + Left$(sName, Ret) + "=" + Left$(sData, RetData - 1) 'prepare for next value Cnt = Cnt + 1 sName = Space(BUFFER_SIZE) sData = Space(BUFFER_SIZE) Ret = BUFFER_SIZE RetData = BUFFER_SIZE Wend 'Close the registry key RegCloseKey hKey Else Me.Print " Error while calling RegOpenKey" End IfEnd Sub
How To Write A Recursive Function?
Hi,
I'm trying to write a recursive function but in vain... thus i sincerely hope you could help me... Actually my purpose of this recursive search is to search for all children, grandchildren, great grandchildren...etc of a particular record. Suppose in my table, I have two fields, Parent and Child.
For example,
Parent Child
===== ====
May - John
Jess - Mike
Jess - Nick
John - Peter
John - Jess
John - Watson
Peter - Carrie
........ etc
Suppose I start with a name John. My aim is to 1st search thru the parent field for all records with parent, John. In this case, the records will be those of children Peter, Jess, and Watson.
For each of these children, I will search thru the table again, for their children (aka John's grandchildren)..
Thus I need a recursive method to traverse thru the records.
Can anyone help?
Thank you very very much.
Recursive Function Calls
In order to generate a unique number I wrote the following simple Function. It fails to do the job because there is no recursive Function call. However, using an analogous Subroutine works because the desired recursive call to the Sub _does_ happen.
Is this a VB feature, and, if so, why?
Public gcollUniqNum as New Collection
Public glUniqNum as Long
Public Function UniqueNum() As Long
Dim lNum As Long
lNum = GenRan(1)
If InColl(gcollUniqNum, CStr(lNum)) = True Then
'NO recursive call to UniqueKey.
'Function exited with UniqueKey = 0
lNum = UniqueKey
Else
gcollUniqNum.Add lNum, CStr(lNum)
UniqueNum = lNum
End If
End Function
Public Sub GenerateUniqueNumber()
Dim lNum As Long
lNum = GenRan(1)
If InColl(gcollUniqNum, CStr(lNum)) = True Then
'DOES result in recursive call
GenerateUniqueNumber
Else
gcollUniqNum.Add lNum, CStr(lNum)
glUniqNum = lNum
End If
End Sub
Public Function InCollection(collDesignated As Collection, Key As String) As Boolean
On Error GoTo NotThere
'VB generates a run-time error if Key is not in collDesignated
If collDesignated.Item(Key) <> "" Then
InCollection = True
Exit Function
End If
NotThere:
End Function
Need Help With Treeview Vb6 Recursive Function
Hi ,
What I am trying to achieve is the ability to limit the checked nodes to 1 only.
Within the London's node there are 2 children (show1,show2) only one perfomance can be checked
In my attempt I set all to false and then the selected one to true.But i m failing to recursely loop.
Can you help?
Scenario
Country
City
London
show 1
Cinderella 20/06/06 performance
Cinderella 21/06/06 performance
show 2
Phantom 20/06/06 performance
Phantom 21/06/06 performance
My failed attempt
Code:
Private Sub ValidateNodes(ByVal ndParent As MSComctlLib.Node)
dim oChild as MSComctlLib.Node
Set oChild = ndParent .Child
For iIndex = 0 To ndParent .Children - 1
oChild.Checked =false
Set oChild = oChild.Next
Next
tvw.SelectedItem.Checked=true
End Sub
Thanks in advance
List All Files (recursive Dirs)
I've already tested the FindFirst/FindNext API. This is a fast solution to list all files in a dir and subdirs but ... I found that if a dir as more than 2 dots in its name like "dir.name.123.abc" the files inside thoses dirs are ignored in the return listing.
What process do you use to list all files in a dir (and recursive) that return 100% of all files?
Thank you in advance for any comment.
Best regards.
Recursive Function In Formula Not Working?
I am trying to use a recursive function to return the number of levels for a specific parent but once I put the function in an equation it doesn't work. I receive a "ByRef Argument type mismatch error" for Level(Temp) which is fine when on a stand alone line.
Code:
Function Level(Parent As String) As Integer
Dim Temp As Variant
Temp = DLookup("[Component]", "TestData", "[ItemNo] = '" & Parent & "'")
If IsNull(Temp) Then
MsgBox ("Found NULL")
Level = 1
Debug.Print "ItemNo Component", "Level"
Debug.Print Parent; " "; Temp; " "; Level; Chr$(13)
'Done
Else
MsgBox ("Found ItemNo")
Debug.Print "ItemNo Component", "Level"
Debug.Print Parent; " "; Temp; " "; Level; Chr$(13)
'**** This Works Fine
Level (Temp)
'**** This Doesn't Work, Why?
'Level = Level + Level(Temp)
End If
End Function
Any help would be appreciated. Thanks.
Fully Kill Recursive Function
Hi all,
I have a bit of a problem with a recursive function. Basically what the function does is search for files, I used some code from an FAQ or post here on vbcity and it works very well. Below is the definition, you may know the funciton i mean from it.
Code:
Function GetAllFiles(ByVal path As String, ByVal filespec As String, _
Optional RecurseDirs As Boolean) As Collection
Basically in my program you click a button on the main form and a dialog box pops up, with a listview and 2 buttons on it. You then choose to browse for a file (common dialog box etc...) or search for a file. The search for a file button opens another dialog box with a listview and search buttons and you type your search in and then the search begins. It prints any matching files into a listview. You then select which files you want and click another button, which adds the selected items to the first dialog box's listview. You can click OK and the dialog will close and you will see all the files you picked. This works fine.
The problem occurs when you dont wait for the search to end. There are DoEvents commands in parts of the recursive search function so the listview will show a file as it is found. This also means you can select it and add it whilst the search is still running (which is good, i want this). However you can also click ok and go back to see the files you've selected, but the search is still running. If you quit the program, it will still remain in task manager. I want the search to stop the minute OK is clicked (the only code for ok at the moment is unload me). Any ideas how you can do this, if at all?
One other thing, if I click ok whilst a search is running, and the dialog closes, and then I click search again to open the dialog back up, it will display any matches it finds as the previous search runs (ie ones that were not shown before, new ones that the halfway through search finds)
All help much appreciated
Dan
Calling A Recursive Function/sub From Itself Sends Nothing
first :thank you delcom5 for your reply.
i built a recursive function (tried calling it a sub as well - same problem)
that should builds nodes from DB to be added to a treeview.
and when i call the function from itself the node is sent as nothing (i do add byval of course).
don't have a clue why this shold happen, other parameters are sent just fine.
Recursive Function Fails To Return The Correct Value
Hi,
I'm fairly new to VB. Just tried to implement a recursive function with Tree Class. The function is as follow:
Code:
Private Function bTreeSearch(ByRef tmpx As Node, _
ByVal result As Integer, _
ByVal expr As String) As Boolean
Dim isFound As Boolean
If (tmpx Is Nothing) Then
isFound = False
Else
isFound = (tmpx.result = result)
If Not isFound Then
If result < tmpx.result Then
bTreeSearch tmpx.Left, result, expr
Else
bTreeSearch tmpx.Right, result, expr
End If
End If
End If
bTreeSearch = isFound
End Function
When I ran through debug mode, I found out that when the function found the node with the same result and set isFound = True, on the way returning to the stack, ie. back to its previous copy, where isFound is False, it returns FALSE as the value of the first copy of the function rather then TRUE value of the second copy - I hope you understand what I am talking about.
My question is, how to make this recursive function to return the TRUE value (from the second copy of the function) as the function rolls back on the stack?
(still N00b) Recursive Function Doesn't Work
Hi,
For some obscure reason an recursive function I build doesn't work:
Code:
Public Function D()
Dim TD As Integer
Dim XD As Integer
XD = 0
TD = D10
If TD = 10 Then
XD = TD + D
Else
XD = TD
End If
D = XD
End Function
D10 is a function that gives a random number between 1 and 10
What it must do is:
When D10 results in 10, then another D10 must be added:
If TD = 10 Then XD = TD + D
but for some reason VB doesn't 'step into' D and just gives the result '0'
At first I used If TD = 10 Then D = TD + D, which is shorter, but same result.
Any clue anyone?
Problem With Recursive Function To Build XML Dom Tree
I have the following recursive function
Private xmldoc As DOMDocument30
Private Sub BuildTree(ByRef parentElement As IXMLDOMElement)
Dim aElement as IXMLDOMElement
...
Set aElement = xmldoc.createElement("something")
parentElement.appendChild aElement
...
BuildTree aElement
...
End Sub
Running the code results in: "Compile error: ByRef argument type mismatch"
Could anybody help identify the problem and suggest a solution for it?
List Box, Instr Function, And Sequential Access File
This is an exercise from my book I have to do. I am stumped on it and don't know where to start.
The main program design has one list box on the left and one on the right. The list box on the left has full-time, full-time/new cars, full-time/used cars, new cars, part-time, part-time/new cars, part-time/used cars, and used cars in it. When you click on one of this it is supposed to list the names of these employees in the list box on the right. The names of the employees are located in a .dat file along with F1, F2, P1, P2 next to there names whether they are full-time (F), New Cars (1), Part-time (P), Used Cars (2). The first list box is named lstChoices, the second one is lstNames and I'm supposed to code lstChoices click event so that it displays the appropriate listing in the lstNames list box (Hint: Use the Instr function). This is all the information I have. The items are already added to the first list box, so I'm stuck beyond this point. Any advice would be appreciated, or if something like this has been posted before please tell me where I can find it. Thanks.
BTW, I'm using VB 6.0
DJ2005
Recursive File Operations
I have a function to apply to a file, one at a time, and I need the user to be able to drag files and folders onto a command button to do it. So far, it can loop to handle more than one file and distinguish between directories and files. I'd like it to be able to accept multiple files and directories, and recursively perform the function on all files within the directories. How would I do this?
Code:
Private Sub cmdButton_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, Y As Single)
For Each Item In Data.Files
If GetAttr(txtFile.Text) And vbDirectory Then
'It's a directory
'Nothing can be done
Else
'It's a file
ProcessFile Item
End If
Next
End Sub
Recursive File Search
Hey
First off the code im posted isnt all mine, i got it from:
http://www.mvps.org/vbnet/
And adjusted it by removing things i didnt need and updating the names of controls on the form. The code is extremely fast and works fine, the only problem is i cant seem to save the File details to the same file (The code attached doesnt attempt this).
I assume the details are in the WFD type however when accessing this or attempting to save these extra details to the same file i get blanks in a lot of entries.
Basically, does anyone know an API function that will scan through the hard drive, but will allow file details to be saved to? I can only get the code below to save file names correctly, unfortunately.
Thanks a lot.
Gav
Recursive Function &"out Of Bounds Error&"
I got that function from here but I get ann error "subscript out of range" what`s up with that ??
'recursive folder adding
Public Sub ProcessFiles(d As String)
Playlist.files.AddItem Playlist.files.ListCount + 1 & ". " & d
End Sub
Public Sub ProcessDir(strDir As String)
Dim i
Dim iCount As Integer
Dim Result As String
Dim FileList() As String
iCount = 0
Result = Dir(strDir & "*.*", vbDirectory)
Do While Result <> "" ' Start the loop.
If Result <> "." And Result <> ".." Then
iCount = iCount + 1
ReDim Preserve FileList(1 To iCount)
FileList(iCount) = strDir & "" & Result
End If
Result = Dir
Loop
For i = 1 To UBound(FileList)
If (GetAttr(FileList(i)) And vbDirectory) = vbDirectory Then
ProcessDir (FileList(i))
Else
ProcessFiles (FileList(i))
End If ' it represents a directory.
Next
End Sub
Feedback Please - Recursive File Search / Info Grabber
I've been tinkering around here on this module to see what sort of solution I could come up with for searching and returning filenames, times, sizes and attributes for all files found, searching with wildcards and recursing subdirectories.
The attached module is what I have come up with to date.
I'd be interested on any feedback from anyone out there, especially in regards to the file times and sizes for large files (2.2GB and above). Anyone watching my posts over the past few days will know what I mean.
Thanks everyone for your feedback and help.
Help With File List , Dir List And Drive List Boxes..
How do i link my drive list , file list and dir list boxes to gether , so that when i for exaple set the drive list to c: , the dir list will then give all dir in there, and file list will show me files from the directory, right now the default file list is set to my vb file list and i cant change it...
From A Function To A List Box
Anyone done this before.
I want to populate a listbox on a form from a complex function.
I thought I could populate a collection, but it doesn't want to work. In essense, it needs to be something like this:
Code:
lbOne = FillList(sField, bTrue)
Public Function FillList(sfield as string, bTrue as boolean) as Listbox
<get a bunch of data>
<move the data back to the list box>
End function
Any ideas?
DLL Function List
Hi!
I am working on loading DLL's dynamically in VB (LoadLibrary, ...) because the DLL's are not known at compile time of the software.
This works fine, but I have 2 more or less easy questions:
1.) Is it possible to get a list of all functions in this DLL (not with e.g. dependency walker, but within VB).
2.) Is it possible to get the parameter list for a dedicated DLL function (as it is displayed in the Object Catalog when I add the reference in Visual Basic)?
Regards,
Martin.
List Function
Hey, I'm trying to add a string with a number at the end of it to list1. I am putting a number in txtnumber.text, the main string in txtstring.text, and then trying to add txtstring.text & 0 - txtnumber.text so i would end up with
string0
string1
string2
string3
string4
etc..
Thanks
VB Function List
Does anyone know where I can find a list of built-in VB Functions?
API Function List
Hi all,
is there a list of API Functions available?
is there maybe a file I can download from Microsoft?
Thanks, Hans
Library Function List?
In a typical C manual -- such as O'Reilly's "Posix Programmer's Guide" -- if I want to format date/time, I look up some appropriate sounding function name. Turns out to be strftime(). (Shocking development, but stay with with me. ) However, simply calling strftime() will not do: The library must be included as well. In this the strftime() listing tells me it is time.h.
Now, the Visual Basic issue:
It appears from the MSDN documentation that VB 6.0 comes with date/time controls such as DateTimePicker and MonthView. Unfortunately, it does not tell me what library to add to the toolbar so that I can drag the control onto my form. In fact, none of the control listings that I have seen mention what needs to be places on the toll bar to access the control. That's like having an index with no page numbers.
Is there some way of determining what libraries contain what Visual Basic controls and functions?
Function Auto List
HI,
Is it possible to create functions that have an auto list box appear for some of its arguments, such as the ones you see with the msgbox function (where the list drops down with vbcritical, vbOk etc....). Thanks in advance, Shaun.
The SendToWinPopup Function Is List
The SendToWinPopup function is listed in a number of locations as a tip. It uses a mailslot to send a message and supposedly windows will popup a message on the target machine for the recipient. I have built the function, compiled it cleanly, run it and get no message. My return value is 0 for the function. What am I doing wrong?
Private Declare Function CloseHandle Lib _
"kernel32" (ByVal hHandle As Long) As Long
Private Declare Function WriteFile Lib "kernel32" (ByVal hFileName As Long, _
ByVal lpBuff As Any, ByVal nNrBytesToWrite As Long, _
lpNrOfBytesWritten As Long, ByVal lpOverlapped As Long) As Long
Private Declare Function CreateFile Lib _
"kernel32" Alias "CreateFileA" ( _
ByVal lpFileName As String, _
ByVal dwAccess As Long, _
ByVal dwShare As Long, _
ByVal lpSecurityAttrib As Long, _
ByVal dwCreationDisp As Long, _
ByVal dwAttributes As Long, _
ByVal hTemplateFile As Long) As Long
Private Const OPEN_EXISTING = 3
Private Const GENERIC_READ = &H80000000
Private Const GENERIC_WRITE = &H40000000
Private Const GENERIC_EXECUTE = &H20000000
Private Const GENERIC_ALL = &H10000000
Private Const INVALID_HANDLE_VALUE = -1
Private Const FILE_SHARE_READ = &H1
Private Const FILE_SHARE_WRITE = &H2
Private Const FILE_ATTRIBUTE_NORMAL = &H80
Private Const MY_COMPUTER_NAME = "aquarius"
Private Const MY_NAME = "Steve King"
Function SendToWinPopUp(PopFrom As String, _
PopTo As String, MsgText As String) As Long
' parms: PopFrom: user or computer that ' sends the message
' PopTo: computer that receives the ' message
' MsgText: the text of the message ' to send
On Error GoTo HandleErr
Dim rc As Long
Dim mshandle As Long
Dim msgtxt As String
Dim byteswritten As Long
Dim mailslotname As String
' name of the mailslot
mailslotname = "\" + PopTo + _
"mailslotmessngr"
'msgtxt = MY_NAME + Chr(0) + PopTo + Chr(0)
msgtxt = PopFrom + Chr(0) + PopTo + Chr(0) + _
MsgText + Chr(0)
mshandle = CreateFile(mailslotname, GENERIC_WRITE, FILE_SHARE_READ, 0, _
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
rc = WriteFile(mshandle, msgtxt, _
Len(msgtxt), byteswritten, 0)
rc = CloseHandle(mshandle)
Exit_Proc:
Exit Function
HandleErr:
Call HandleTheError("basSendToWinPopup", "SendToWinPopup", Err)
GoTo Exit_Proc
Resume
End Function
Steve King
Growth follows a healthy professional curiosity
Use A Function Output In A List Box
Hi,
I'm a rookie in the area, my problem is:
I have a function that when I run it, it gives me a output in the Immediate Window. What I need is to put that output in a ListBox, how can I do it?
Thank you very much.
Andre
PHP (List Function) To VB (what The Equivilant)
Yo yo yo
I learned most of the programming theroy useing PHP and now I need to use it in VB
In PHP I have a small parcing script used to parce big file - now I need to do that in VB
Code:
$line = "Hello/World/foo"
list($name, $format, $release) = split ('[/]', $line);
echo $name; #will return Hello
echo $format; #will return World
echo $release; #will return bar
Now in VB I can do almost all of that
Code:
Dim SString as String
Dim x as String
SString = "Hello/World/foo"
x() = Split(x, "/") 'Yea I could do this but I rather have it like my php script
Is there any List function in vb that I can use??
Edited by - Cerf on 8/5/2003 11:09:29 AM
Populating A List Box With A Function
Hi, I'm trying to populate a list box with a function. The function will gather the names of all the queries (in my Access 97 database), put them in an array, and display them in the list box. When I run the code below there are no errors, but nothing is displayed. The list box Row Source Type is set to 'getQueries', but still nothing is displayed.
Any help will be really appreciated.
Function getQueries(fld As Control, id As Variant, row As Variant, col As Variant, code As Variant) As Variant
Static qry(100) As String
Dim Entries As Integer
Static ReturnVal As Variant
ReturnVal = Null
Dim db As Database
Set db = CurrentDb
Select Case code
Case acLBInitialize
Entries = 0
With db
Do Until Entries = .QueryDefs.Count Or Entries >= 100
qry(Entries) = .QueryDefs(Entries).Name
Entries = Entries + 1
Loop
End With
ReturnVal = Entries
Case acLBOpen
ReturnVal = Timer
Case acLBGetRowCount
ReturnVal = Entries
Case acLBGetColumnCount
ReturnVal = 1
Case acLBGetColumnWidth
ReturnVal = True
Case acLBGetValue
ReturnVal = qry(row)
Case acLBEnd
Erase qry
End Select
getQueries = ReturnVal
End Function
An API Function To List All The Network Connections?
If you type "netstat -n" in a command prompt, you will get a list of all active and established connections your computer has made. I'm looking to retrieve the list of established connections. I scanned the API lists but I couldnt find the one to do it... but it has to be there. Does anybody know how this would be done?
Function To Put A List Of Items Into An Array?
Isn't there a function that can take a list of items and put them into an array?
I searched for it unsuccessfully but it seems like I've seen it before when I didn't need it.
For instance I've got a string that contains a list of arguments separated by commas and I want to shove each of the args into the elements of a single array.
agr1,arg2,arg3,arg4
Help?
List Box Seek/search Function
Hey guys,
i have a list box which must be searched using a text entered into a seperate text box, the stuff needs to be searched as i
type. similar to search in Windows Media player 11
as in.. if i type letter 'a' then all but the items starting with a must dissapear. if i type 'as' then all but items
starting from 'as'
if i delete everything then, all the list must appear.
Does anyone know how to implement it.. i've tried but doesnt seem to work..
my Code
----------------------
Private Sub txtSearch_KeyPress(KeyAscii As Integer)
Dim i As Integer
Dim TotalItems As Integer
TotalItems = lstUsers.ListCount - 1
lstUsers.Clear
For i = 0 To TotalItems
If Left(lg_UserArr(i), Len(txtSearch)) = txtSearch.Text Then
lstUsers.AddItem (lg_UserArr(i))
End If
i = i + 1
Next
End Sub
---------------------
I fill a seperate Global Array, lg_UserArr when the records are being added..
help anyone?
thanks
Function To Put A List Of Items Into An Array?
Isn't there a function that can take a list of items and put them into an array?
I searched for it unsuccessfully but it seems like I've seen it before when I didn't need it.
For instance I've got a string that contains a list of arguments separated by commas and I want to shove each of the args into the elements of a single array.
agr1,arg2,arg3,arg4
Help?
How To Make A List Appear In A Function Program VBA Code?
When we use a Function like Msgbox we see that appear a "list" or cascade "list" of options to select like "Information, Warning, OKCancel, etc." or other example is when we use a boolean variable. When we asign the value appears a little cascade with de "True, False" options...
My question is What can I do in the elaboration of the Function (any Function) to make appear the options I need in a cascade...
Please...Help...
Luis
|