|
Hello...
I ran into an interesting situation yesterday when writing some code behind a form in MS Access 2003.
On change for a textbox I wanted to search a list of parts so as the user typed in the part number the code would search down the list and find the first match. My problem was it took a little longer then what I expected.
I would like to try to make this a multi-threaded app where I do the search in another thread and return control to the screen. Would I need to use C# or VB.NET and create an add-in or is there a way to create new threads?
Thanks
Will
|
|
|
|
|
The VB6 IDE cannot handle debugging a multithreaded app. If you stop the execution ANYWHERE in your code while another thread is running, you'll instantly crash the IDE.
I'm not saying that it's can't be done, it's just very difficult to do.
A speed improvement to your search would probably be in indexing your primary search field.
Another one is if your using something like
SELECT * FROM table WHERE something LIKE 'som%'
The '*' represents returning all fields in all the records that match the search criteria. Don't do this. Narrow it down to only the fields you need to return.
SELECT field1, field2 FROM table WHERE something LIKE 'som%'
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thank you for the reply.
Couple things:
1) The view that I an using is linked from SQL Server and yes the table has been normalized
2) I am searching a listbox that has been populated and not hitting the view at all
Let me post some code to clear this up a little
TEXTBOX EVENT:
<br />
<br />
Private Sub txtPartSearch_Change()<br />
'<br />
' Created by William O'Malley<br />
' I would like to user to be able to type in part of a Part Number<br />
' and have the list activly search for a match baised on what is typed in<br />
'<br />
' Ex:<br />
' If I type in 12 then go to the first match<br />
' if I type in 1234 then go to the first match<br />
'<br />
' This will happen as they type<br />
'<br />
Dim sLength As Integer 'how long is the string<br />
Dim sSearch As String 'what am I looking forgy<br />
Dim iListCount As Long<br />
'<br />
'<br />
sLength = Len(Me.txtPartSearch.Text)<br />
sSearch = Me.txtPartSearch.Text<br />
iListCount = Me.lstPartNumbers.ListCount<br />
'<br />
Me.lblSearchingOf.Caption = Me.lstPartNumbers.ListCount<br />
'<br />
findInListBox sLength, sSearch, iListCount<br />
'<br />
End Sub<br />
<br />
FUNCTION USED TO SEARCH:
<br />
Function findInListBox(ByVal sLength As Integer, ByVal sSearch As String, ByVal NumberOfRowsToSearch As Long)<br />
'<br />
' This function will be used to perform the search on<br />
' the list box<br />
'<br />
Dim i As Long<br />
Dim sStringToCheck As String<br />
'<br />
For i = 0 To NumberOfRowsToSearch<br />
'<br />
Me.lblSearching.Caption = CStr(i + 1)<br />
sStringToCheck = Left(Me.lstPartNumbers.Column(0, i), sLength)<br />
'<br />
If (sStringToCheck = sSearch) Then<br />
'<br />
Me.lstPartNumbers.Selected(i) = True<br />
'<br />
Exit For<br />
'<br />
End If<br />
'<br />
Next i<br />
'<br />
End Function<br />
Although this only takes a few seconds I want it faster. So I figured that I could call my findInListBox function in a new thread that and return control to the screen. So the user would be able to continue typing as fast as they want with no problem because the search would be in the background.
Thank you again for the reply.
William O'Malley
-- modified at 9:00 Friday 9th September, 2005
|
|
|
|
|
OMalleyW wrote:
2) I am searching a listbox that has been populated and not hitting the view at all
OK. You didn't mention this before...
Instead of do string comparisons, my only suggestion would be to build an index tree of the data in the listbox. When you hit a key, you're search only returns items that start with that letter. With the next key, you only search the items returned from the first search. When the third key is his, you only search the items from the second search, and so on, ...
Check out this[^] series of articles on MSDN for some theory and examples.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thank you for the link and info...
When I figure this out I will post my new solution.
Thanks!
Will
|
|
|
|
|
Can anyone help me?
I have 4 textboxes 1,2,3,4
How as you enter a value in a textbox that it automatically update say textbox4 which is a readonly box.
What is the code to do this. Tried a few ways but getting frustrated now with lack of success
-- modified at 7:07 Friday 9th September, 2005
Got it I think.
Use the TextChange or KeyUp event
|
|
|
|
|
I already told you how to do it and I even gave you the code, back on Sept. 5th. How about you post the code you're using and we'll show you how to fix that?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
No need as I found the code you gave me on the 5th September. I applied it to my code and its working.
Thanks for suggesting that I post my code to you to fix it but as stated, no problem now
Thanks again
|
|
|
|
|
I am creating a new VB.NET application where I have a base form that inherits from System.Windows.Forms.Form. Within that base form I have put a number of panels on the form, using docks or anchors for each to layout my sections. This base form has been copiled as part of a class library to be used in describing an application.
I have then created a VB.NET windows application project with a main form that inherits from my base form in the class library that I have created. The dll for this is referenced in my new windows application.
When I open my main form in the windows application I can see all the panels in the correct layout, these panels modifiers have been set to protected friend in the base form so I can add new controls to them in the main form.
Everything works well until I start to add controls to them or try to create event handlers for these panels. In the main form code window, I cannot see the panel objects in the list of objects with events, in order to select an event to use in the declaration drop down list. I can manually add an event handler in code. If I do either of these things, the designer decides to bugger up the layout of the inherited panels.
The only way I can reset them, is to change the inherits from in the main form to System.Windows.Forms.Form then back to the base form.
Everything looks OK again then in the designer and when I run the application, until I make any changes in the main form which in turns buggers up the layout of my inherited panels.
Are there any known issues in VB.NET with what I am trying to achieve, and advice would be appreciated.
Cheers
Jason
|
|
|
|
|
I wrote code which can tell you homepath of current user logged in to the machine.... I used certain key value pairs which work fine on XP, but gives error when I run this application on windows 2003.
I noticed that certain registry key pairs are different for different operating systems..
What should I do to get homepath of current logged in user
|
|
|
|
|
You're getting the user's home directory out of the Registry? If so, there's any easier, and more reliable way.
Open a CMD prompt and type SET. You'll find the UserProfile path in the Environment .
Use Environment.<a href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemEnvironmentClassGetEnvironmentVariableTopic.asp?frame=true" rel="nofollow">GetEnvironmentVariable()</a>[<a href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemEnvironmentClassGetEnvironmentVariableTopic.asp?frame=true" target="_blank" rel="nofollow" title="New Window">^</a>] to retrieve the user profile path.
Or, if that's not what you wanted, you can look into Environment.<a href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemEnvironmentClassGetFolderPathTopic.asp?frame=true" rel="nofollow">GetFolderPath</a>[<a href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemEnvironmentClassGetFolderPathTopic.asp?frame=true" target="_blank" rel="nofollow" title="New Window">^</a>] and the <a href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemenvironmentspecialfolderclasstopic.asp?frame=true" rel="nofollow">Environment.SpecialFolder</a>[<a href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemenvironmentspecialfolderclasstopic.asp?frame=true" target="_blank" rel="nofollow" title="New Window">^</a>] enumeration.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 8:10 Friday 9th September, 2005
|
|
|
|
|
thats cool, I never knew you could do that - time to revise some old code I think
/jason
|
|
|
|
|
Hi All,
I want to change the image of a Picture Object of crystal report during run time. i have tried to do this with the PicutreObject (GraphicalObject) of Crytsal report but it does not work as it does not support any property that deals with image.
Pls, if any knows help me.
-Ajay
|
|
|
|
|
Could someone please help me. Here's my code:
Private Sub ToolBar1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ToolBar1.MouseDown
ToolBar1.DoDragDrop(ToolBar1, DragDropEffects.Move)
End Sub
Private Sub frmRolman_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter
e.Effect = DragDropEffects.Move
End Sub
Private Sub frmRolman_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragDrop
Dim myForm As Form
myForm = CType(sender, frmRolman)
Me.ToolBar1.Dock = DockStyle.None
ToolBar1.Left = Me.MousePosition.X
ToolBar1.Top = Me.MousePosition.Y
If Me.MousePosition.Y = Me.Top Then
ToolBar1.Dock = DockStyle.Top
End If
End Sub
My problem is I'm not exactly sure at which position the toolbar should dock at the top, left, etc... With the above code, when I click on the toolbar, it moves. Probably has to do with the mouse_down event, but I'm going off some tutorial code that moved a picture box within the form.
Thank you for your time.
|
|
|
|
|
Hi frends!!!
Well here's the deal, I'm totaly clueless on how to go about this but how can a user bypass a login page when a hyperlink is sent to him/her through let's say MS word?
I usualy try things out 1st and ask questions later when i get stuck but this time i'm lost to begin with so any concept or (hopefully) actual working functions would be awsome! Thnax for all you helps!
Kampai!!!
|
|
|
|
|
If the security on that site is utter crap, then yes, all you have to do is send the link to the page. If the security is decent or better, then no, there is no way to "bypass" the login.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi guys
I am new in visual basic program language, I need your help to solve my problem, at this time I have a program which is connected to access 200 database tables. I want to know how to create a program that can access form automatically to last records on my access database table.
And show the last record into textbox's, I need your help deeply and if you don't mind please give me a sample in order to make sure me can understand how the program should be write.
Thank you for your attention and support to me
Bst regards
I C E
|
|
|
|
|
hi there ice, as to your question...
if you are using ADO technology, just type this code on your button.
ADODC.recordset.movelast
thats it!
make sure your ADO data control is connected to your database.
enjoy!
magnus
|
|
|
|
|
Hi Magnus
Thank you for your assist, it's really valuable for me but in my application I use OLDB, does it same phrase to access last record like ADODC.
Thank you
I C E
|
|
|
|
|
Hi Magnus
Thank you for your assist, it's really valuable for me but in my application I use OLDB, does it same phrase to access last record like ADODC.
Thank you
I C E
|
|
|
|
|
I have a dynamically created RichTextBox control. I also have ToolStripButton for setting the selction string to Bold in the box. What I need to do is be able to catch the selected texts FontStyle as it is selected. i.e. MS Word has the feature that when you click on text that is Bold the bold toolbar icon is checked and when you click on regular text it is not checked. How would I capture the Fontstyle in realtime on a dynamically created control? I hope this makes sense.
Thanks,
Taen Karth
|
|
|
|
|
You need to subscribe to the selection changed event, then hopefully you can examine the selected text for it's font properties.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How in the world do I subscribe to the Selection changed event on the dynamic control. Somewhat new here...
Thanks,
Taen Karth
|
|
|
|
|
I don't use VB, I hate it. If you're using VB.NET, there has been some discussion on events on dynamic controls in the past day or so, search the forum for details.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
ok done some searching and still cannot find an answer... Would anyone else have any advice?
Thanks,
Taen Karth
|
|
|
|