|
Hi all,
I am using the following code for my searching function, but when I try to run it, it are allow me to search the item for column 1, but I want to search the item for column 2 as well columun 3, what mistake I have make, can anyone give me some advice on this?
This is my code:,
Private Sub ListView_Master_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles ListView_Master.ColumnClick
Dim exactMatch As Boolean
Dim mySearchText As String
Select Case e.Column
Case 0 'column one BOM ID
'Search for item at column 0 when user click on column 0
'MsgBox(e.Column)
Case 1 'column two Cust Part # = BOM
'Search for item at column 1 when user click on column 1
MsgBox(e.Column)
mySearchText = Trim(InputBox("Please enter your Customer Part #", "Search Product Master Entry Data"))
For Each itm As ListViewItem In ListView_Master.Items
If exactMatch Then
If itm.Text = mySearchText Then
' an exact match was found ...
MsgBox("Exact")
End If
Else
mySearchText &= "*"
If itm.Text Like mySearchText Then
' a partial match was found ...
MsgBox("Partial")
End If
End If
Next
Case 2 'column three Child Part#A = CodeAChild Part#B = CodeB
'Search for item at column 2 when user click on column 2
MsgBox(e.Column)
Case 3 'column three Child Part#B = CodeB
'Search for item at column 3 when user click on column 3
MsgBox(e.Column)
End Select
End Sub
|
|
|
|
|
Could you clarify please? Do you mean that when the user clicks on column 1 it should search column 1, column 2, and column 3? If that is the case, then you need another loop to cycle through the columns before you cycle through the items.
Or do you mean that when the user clicks column 1 it should search column 1 only, and if they click column 2 it should search column 2 only, and so on? In this case what you are saying is that the code is not hitting the Case 2 or Case 3 of your select statement. Try putting a breakpoint at Select Case e.column . Run your program and click on column 2 or 3. Then when it hits the breakpoint quickwatch to see what column you are on. Maybe that can help point you in the right direction.
Sorry I couldn't be more helpful.
|
|
|
|
|
This might be a simple question ..
actually i want to use a tabcontrol in the mdi form (these tab controls should generate at run time) and these should on the left bottom of the page can any one can tell me how to implement this
thanks in advance
chandra
|
|
|
|
|
here you go, modify as necessary.
'dynamically create a tab control and some pages
Dim tbc1 As New TabControl
'format the tab control
tbc1.Dock = DockStyle.Fill
tbc1.Alignment = TabAlignment.Bottom
'add the tab control to the form
Me.Controls.Add(tbc1)
'add 5 pages
Dim x As Integer
For x = 1 To 5
Dim tbp1 As New TabPage
tbp1.Text = "Page " & x.ToString
tbc1.TabPages.Add(tbp1)
Next
|
|
|
|
|
Hi,
I have a VB.Net app that for various reasons is required to load a dll written in C using the LoadLibrary and (when done) FreeLibrary APIs. For the most part everything works perfectly. However there is a problem with one of the functions in the dll, which simply writes an empty file in the users temp directory. When called via the VB.Net app using the following code:
pFunction = GetProcAddress(hDllInstance, f)
If Not pFunction.Equals(System.IntPtr.Zero) Then
Try
CallWindowProc(pFunction, 0, 0, 0, 0)
Catch ex As Exception
End Try
End If
a System.NullReferenceException is always thrown. The file however is written correctly. The function in the dll is simply:
void CreateTempFile()
{
HWND hWnd = CreateFile(szFilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_HIDDEN, NULL);
CloseHandle(hWnd);
}
The szFilePath parameter is 1024 chars long (ie. no buffer overruns) and contains the name of the file to create. I created a test program in C to load and test the dll functions and this ran perfectly, both standalone and when run stepwise in a debugger. No exceptions or buffer overruns (etc.) occurred.
I am running the VB.Net app with administrator priviledges. Any ideas would be gratefully received.
Thanks
|
|
|
|
|
I don't think CallWindowProc is going to work for you. I also don't think you can make a direct call to unmanaged code like this.
You might want to take a look at this[^] for an example.
There's also a couple of C# examples here[^]. I don't see an reason why the code couldn't be converted to VB.NET.
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 20:12 Thursday 13th July, 2006
|
|
|
|
|
Thanks for your reply, this was much appreciated. In actual fact all the calls to CallWindowProc do work, its just that any call that creates a file also raises an exception. I couldn't access the first example you gave (I'm not a paid up member of Experts Exchange) however the other example has given me food for thought. Thanks again for this.
|
|
|
|
|
Hmmm...Things look like they change at the Experts Exchange. I never paidfor a subscription!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Just out of interest the System.NullReferenceException was being thrown as I had declared the CallWindowProc function as:
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As IntPtr, ByVal hWnd As Long, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As String
I "cast" the return value to a string as I would subsequently call this function again to run procedures in the unmanaged dll that returned string values, and I knew no other way to read a string value from memory in .Net Even though I wasn't using the return value in the initial call to CallWindowProc the interop services obviously still attempted to use the value in eax as the address of a string, with the resulting exception being thrown. Simply declaring the return value as an Integer fixed the problem.
|
|
|
|
|
hi i had get the color through color dialog box and saved them in database nd then i want to set on the form?
then i want to set the color of dalog reading from the datbase but it gives error that cannot change readonly property.
System.drawing.color clr=new color();
clr.A=a;//read from db; //gives error that cannot change readonly property
.R=b;
.B=v//et
now i want to set the form color to this.
this.color=clr;
how to assign values to color variables?
Tasleem Arif
|
|
|
|
|
You can't change a color structure once you created it. Use the FromArgb method to create a color from the color components:
clr = Color.FromArgb(a, r, g, b);
---
b { font-weight: normal; }
|
|
|
|
|
Hi. I was wondering how I could use VB.Net code in VS2005 to split a wave file. I am new here I would like to learn some. I don't want others doing my work for me but I would like suggestions! I want to specify the time at which the wave file would be split into two different wave files where I could then save them as separate wave files. Does anybody have a clue? Please! I really need help!
Came here from VBForums......Thought people here could help me.
"Imagination is more important than knowledge." - Albert Einstein.
|
|
|
|
|
A wave file consists of a header and sound data. The header contains data like sample rate and sample size, that you need to know how the sound data is arranged.
What you need to do is to reader the header and the sound data, and construct new headers for the two new files, and split the sound data at the sample you calculate to be at the specified time.
One good source for file formats is Wotsit's format[^].
---
b { font-weight: normal; }
|
|
|
|
|
Hi, I am trying to populate a ComboBox with the contents obtained within an ArrayList, but instead of putting the names held within the ArrayList, it writes "System.Collections.ArrayList" in the place of the desired names.
Could you take a look at my code and see where I am going wrong.
I am using vb.net 2002 version.
Any help is greatly appreciated.
Many thanks
John
This is the code for the function selectFieldNames :-
Public fieldNames As New ArrayList()<br />
<br />
Public Function selectFieldNames(ByVal strSQL As String) As ArrayList<br />
' select all field names from the selected table<br />
sqlite_cmd.CommandText = (strSQL)<br />
' Now the SQLiteCommand object can give us a DataReader-Object:<br />
sqlite_datareader = sqlite_cmd.ExecuteReader()<br />
While sqlite_datareader.Read()<br />
Try<br />
fieldNames.Add(sqlite_datareader("name"))<br />
MessageBox.Show(sqlite_datareader("name"))<br />
Catch es As Exception<br />
MessageBox.Show(es.Message)<br />
End Try<br />
End While<br />
Return fieldNames<br />
End Function
This is the code for populating the ComboBox :-
Private Sub frmCreateIndex_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
dbConn.openExistingDatabse("Data Source=" & getDBName() & ";Version=3;New=False;Compress=True;")<br />
dbConn.createSQLCommand()<br />
<br />
Dim a As Integer<br />
<br />
Try<br />
dbConn.selectFieldNames("pragma table_info(test)")<br />
For a = 0 To (dbConn.fieldNames.Count) - 1<br />
cmbFieldIndex.Items.Add(dbConn.fieldNames)<br />
Next a<br />
Catch es As Exception<br />
MessageBox.Show(es.Message)<br />
End Try<br />
End Sub
|
|
|
|
|
You setup an indexer to go through all the elements of fieldNames but you never used it to return an actual element in the array!
Try
dbConn.selectFieldNames("pragma table_info(test)")
For a = 0 To (dbConn.fieldNames.Count) - 1
cmbFieldIndex.Items.Add(dbConn.fieldNames)
Next a
Catch es As Exception
MessageBox.Show(es.Message)
End Try
Should be:
Try
dbConn.selectFieldNames("pragma table_info(test)")
For a = 0 To (dbConn.fieldNames.Count) - 1
cmbFieldIndex.Items.Add(dbConn.fieldNames(a))
Next a
Catch es As Exception
MessageBox.Show(es.Message)
End Try
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi, thanks for this, works a treat, I can't blieve I forgot to use the array.
Thanks again
John.
|
|
|
|
|
I want to develop sqlserver monitor ,tunerand analyzer please can you guide me how can i do this .. just give me a guideline .. or any opensource lib and prj u know
Features should include: Monitor SQL Server Hardware
requirements are
Utilization and Performance
Monitor CPU, memory, and the I/O subsystem percentages
Monitor disk operations (reads/writes) and network traffic
Correlate system utilization with user connections and SQL code
Diagnose Executed SQL Code Performance, Connections, and SQL Server Blocking
Analyze and chart slow performing SQL statements and stored procedures
Report the cost (Duration, CPU time, & disk reads/writes) of each statement
etc etc
R A M
|
|
|
|
|
SQL Server registers and populates a large number of performance counters - you can use the built in .NET class "PerformanceCounter" to get the current values from that for the first part of your requirement.
For the second part use the "SHOWPLAN" T-SQL commands.
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
When I try to view a report inserted as Cerstal Report 11 report, LogOn Failed. I m using Orcle 8i Database.
|
|
|
|
|
I have a table with one column. This table has more than 1500 rows.
I want to print those 1500 rows of one column using 4 columns in the report(rdlc).
How is it possible?
|
|
|
|
|
This thing has driven me nuts the entire afternoon!
We have this unit to which we communicate over serialport that wants messages
in Unicode code points where C = 43, D = 44 etc.
If I want ASCII value for A i use Microsoft.VisualBasic.Asc("A") and get 65, problem is that A in Unicode is 41.
What to do??
|
|
|
|
|
|
jimithing77 wrote: A i use Microsoft.VisualBasic.Asc("A") and get 65,
As it should be. The decimal ASCII value is 65.
jimithing77 wrote: problem is that A in Unicode is 41
Not, it's not, it's 65. Convert decimal65 to hexadecimal and you get 41, or in VB notation &H41.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I'm sure there is a way to do it. But I don't have time to look, so I was just going to suggest that if you can't find a way, you could always write your own function that looks it up for you, like this:
Public Function GetCode(str as string) as Integer
Select Case str.Trim.ToUpper
Case "A"
Return 41
'Continue with other cases...
End Select
End Function
Or if you discover that the Microsoft.VisualBasic.Asc is consistant you could just say cint(Microsoft.VisualBasic.Asc(char)) - 24
Sorry I couldn't find a nicer answer.
|
|
|
|
|
Ah... I did think they were the same, but I didn't spot that little wrinkle when I read it, I just filed it as something to check on later.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|