|
Answered Questions For July 2000
I hope this helps
|
|
Update To Rounding Numbers Question
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Rounding NumbersFrom: Andrew Weller
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Print Data Reports in LandscapeFrom: Nikos Miaoulis
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Update To Form Display Question
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
WinFax?From: Philip Goode
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Form DisplayFrom: RAHEENA QAIYUM
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GIF Files & VBFrom: Kanin Kalra
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Why not create a bulletin board?From: PKM_HercZ
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Telnet???From: Jason Carney
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Roll your own filesFrom: Brian Haley
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
VB & OutlookFrom: Ramon Morales
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Access 97 & ADOFrom: Bill Wolf
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ActiveX DLL'sFrom: Simon Smulovitch
|
A Standard DLL: This is a collection of functions that are Exportable to other programs, any Win32 application can load the DLL and call these public functions. A DLL is usually created so different applications can share the same code, for example, shared code for Microsoft Office, this reduces code bloat and makes bug corrections easier. Another reason for this type of DLL is to expose functionality for unrelated applications in the form of an API. | |
An ActiveX DLL: Although this type of DLL is also used to share code, it is not just a collection of functions, it is designed to be a class server. To gain access to functions and subs, you must create a variable reference to a class within the DLL. For example RS.MoveNext, MoveNext is a sub within the RS (ADODB.Recordset)class. This type of DLL is also known as a COM/DCOM DLL, depending on where the DLL is located in reference to the client application (COM if it is local, DCOM if it is sitting on a network somewhere). |
As of version 6, Visual Basic can only create the ActiveX/COM type of DLL, where as C or C++ can create both. In order for you to be able to use an ActiveX DLL, your application MUST BE COM compliant or at least COM aware. So, herein lies your problem, you are trying to create a standard DLL from an ActiveX DLL, and/or I would bet dollars to donuts that the CGI is not COM compliant and is trying to load your DLL as a standard DLL.
We're working on a database frontend using an MDI with child forms for vendors, customers etc. Presently we use the menuitems and toolbar to navigate through the records. I would like to be able to use the keyboard also, such as pagedown to move to previous record. The MDI form does not have a keydown event. How can I do this?
One form in the MDI Form always has focus, so if you put code in all of the child forms' KeyDown event, you can do exactly what you need. For example: paste in the following code in any/all of your Child forms:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyEscape
cmdClose_Click
Case vbKeyEnd
cmdLast_Click
Case vbKeyHome
cmdFirst_Click
Case vbKeyUp, vbKeyPageUp
If Shift = vbCtrlMask Then
cmdFirst_Click
Else
cmdPrevious_Click
End If
Case vbKeyDown, vbKeyPageDown
If Shift = vbCtrlMask Then
cmdLast_Click
Else
cmdNext_Click
End If
End Select
End Sub
Just make sure you put code behind the command buttons or what ever to move the recordset forward or back.
Hello. I am new at programming, and I am trying to create a program that searches an Access database, at run-time. I want to have a form that lets a person run a query on all fields, by typing one or more words (e.g.: "Toyota AND Trucks"). Another possibility is to have a form with multiple text boxes, with each representing a specific type of info (such as: telephone number, first and last name, street address, etc). When someone types in the correct info in one field and submits, related info shows up in the other fields.
I'd appreciate some direction in this matter. Either a tutorial, or the name of a good, explicit book that covers this topic.
Thank You,
Jerry
This is a toughie, not that the solution is hard, but more in how I will guide you in the right direction in a short amount of space/time. Basically you will want to do some form of Data Binding, most controls like the Textbox, Label, ComboBox ect, have three properties that you are interested in, DataSource, DataMember and DataField. The DataSource creates the connection to the database and can be one of three objects:
The DataMember is the recordset that you want to bind to, the Class or DE can have more then one recordset.
The DataField is the actual database field you want the textbox or whatever to show. You can use the various events, for example, Change(),Validate(),Keypress(), lostFocus() ect, to trap when the user selects Toyota or whatever, and pass a new SQL statement to the DataMember, this will then cascade the new data to other controls bound to that DataMember.
As a beginner to VB, I would recommend Mastering Microsoft Visual Basic 6.0 Fundamentals this will guide you in getting started in VB and Data Access with data binding ect.
From there, I always recommend Mastering Microsoft Visual Basic 6 Development This book/CD gets more in-depth with Data Access and VB.
Thank you first! I'm a VB developer from Burkina Faso. I want to develop a TCP server tha can handles about 30 clients. It 's main function is to lisen and estalish a connection then process a query from the client and then disconnect. It must be multi-threaded ! I can use the Winsock control an the multi-threaded but i would like to use the winsock api. (wsock32).
Thank you last !
I do not have a heap of experience using the Winsock control or the Winsock API, but, I can guide you in the right direction. Your choice of using the API over the control does make things easier to create a nice, neat, multi-threaded layer, that you can reuse in other applications. Create a new ActiveX EXE project, an ActiveX EXE will create one thread per object (class), paste all the Winsock API declarations in the declarations section of the class, then add a property called PortNum and two methods, Connect() then Disconnect(). do not forget to add all of your Query code too.
Compile the EXE and add a reference to your ActiveX EXE in your main application. Now, all you have to do is create a collection of the same type as your main ActiveX class, add 30 classes to that collection, passing the port number you want to listen on, and away you go. You now have a fully, multi-threaded, application (31 threads, one for each class plus one for the main app). You can ether call the disconnect method or just remove the class from the collection to stop listening to the port.
I hope this helps
Dear G,
While some routine is running for some time the forms does not respond to any messages, am I right. I want be able to stop the routine from executing when I say click a Button on the dialog box or when I hit the keyboard. The keyPress event and buttons does not respond when the routine is in the loop for obvious reasons. Is there something that I could use to force the program to execute curtain events when they occure. Or what do you do to overcome this. Thanks H Ps I'm using single Stringing or threading or what ever you call it.
Basically, you are experiencing a classic
case of thread blocking; when you enter a loop, thread
execution stays in that loop, and your application will not
check it's message queue for input. Not only is this
frustrating for the user, because the user will think that
your application has crashed, but the operating system will
think your application has crashed too, because your
application has not checked the message queue for an
acceptable amount of time. How you prevent this is by using
the VB function call, DoEvents().
DoEvents yields control to the operating system. Control is returned after the operating system has finished processing the events in its queue and all keys in the SendKeys queue have been sent.
Now, there are two ways to implement the DoEvents call, the
first is as follows:
Public Sub MySub()
Do while Myrs.EOF = False
DoEvents
FistName = MyRs!FirstName
If not MyRs.EOF then MyRs.MoveNext
Loop
End Sub
This example will work quite well for your needs, BUT, it is a terrible waste of CPU time. The loop iterations will execute very quickly; during iteration, you keep checking the message queue & yielding thread time, defiantly over kill, plus your code will slow down considerably. What we need is a happy balance between the two, that is where the GetInputState() API call comes in to play. The GetInputState function determines whether there are mouse-button or keyboard messages in the calling thread's message queue. If the queue contains one or more new mouse-button or keyboard messages, the return value is nonzero. If the there are no new mouse-button or keyboard messages in the queue, the return value is zero. So let's put it all together:
Paste this code into the Declaration section of a BAS file if you want the whole Application to use it, or paste into the Declaration section of your form if you want it only for that form:
Public Declare Function GetInputState Lib "user32" Alias "GetInputState" () As Long
Next, we will re-write the last example to use the GetInputState call:
Public Sub MySub()
Do while Myrs.EOF = False
If GetInputState then DoEvents
FistName = MyRs!FirstName
If not MyRs.EOF then MyRs.MoveNext
Loop
End Sub
This version of the code will run up to 20% faster then just using DoEvents alone.
You will now have no problem processing a KeyPress or Button_Click event while your loop is executing. If you had a Form or Global Boolean variable called StopProcessing, you could then do the following:
Public Sub MySub()
Do while (Myrs.EOF = False) And
(StopProcessing = False)
If GetInputState then DoEvents
FistName = MyRs!FirstName
If not MyRs.EOF then MyRs.MoveNext
Loop
End Sub
Private Sub Command1_Click()
StopProcessing = TRUE
End Sub
Note: You should also use the DoEvents call as the first line of code in a Form_Load event if you have placed any code in your Form_Initialize() event, this will help to synchronize all the events. For example, if the system has not finished creating an object you created in the Form_Initialize event, but you try to use it in form load, you could cause an error, and this error might not happen every time. Buy placing a DoEvents first, this will help to minimize these errors.
Send mail to WebMaster with
questions or comments about this web site.
|