|
I actually do get an error saying that list has changed. It also says something about an enumerator. Does'nt make sense to me.
Here's the code:
For Each item As String In ListBox1.Items
If ListBox1.SelectedItems.Contains(item) Then
MessageBox.Show(item & "|" & True)
Else
MessageBox.Show(item & "|" & False)
End If
Next
I only get one messagebox for the first item, wether its selected or not, but then i get that error.
Virtual Space Shuttle Astronaut
|
|
|
|
|
Hi,
sorry I didn't know this, it seems one cannot iterate both Items and SelectedItems like that at the same time.
I did come up with this code, which works fine:
Private Sub ListBox1_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedValueChanged
Dim s As String = ""
For i As Integer = 0 To ListBox1.Items.Count - 1
Dim item As String = ListBox1.Items(i)
If ListBox1.SelectedItems.Contains(item) Then
s = s & " +" & item
Else
s = s & " -" & item
End If
Next
Label1.Text = s
End Sub
|
|
|
|
|
|
You're welcome.
|
|
|
|
|
Hi, dear all,
I have a project created in VB.net 2005 and I will collect some user input data based on user selection for calculation.
Since the input data number and content are different based on user selection, I have problem about how to layout these input fields.
For example, the SpeedContrlType is a combobox with value 1,2 and 3, for different value, the set of input data is totall different. If user select value 1, I will show data for type 1 and hide data for other 2 types, same for type 2 and 3.
Can you give me some suggenstion how to organize the form for this case? I don't want to show all data at the same time, then if user select type 1, enable type 1 data set and disable other two sets.
Thanks a lot!
|
|
|
|
|
Andraw Tang wrote: Can you give me some suggenstion how to organize the form for this case? I don't want to show all data at the same time, then if user select type 1, enable type 1 data set and disable other two sets.
The easiest option is to put the UI for each type into Panel . Hide panels number 2 & 3 by default, and switch visibility if the user changes the type.
A better choice would be to move it to a UserControl
I are Troll
|
|
|
|
|
Eddy,
Thank you for your reply.
If I use panels to hold data, I should overlap these panels and make one of them visible according to user selection, right?
What did you mean to move it to UserControl? I am new to VB.net, can you give me more explanation? it's best if you can give me some sample.
Thanks again!
|
|
|
|
|
Andraw Tang wrote: If I use panels to hold data, I should overlap these panels and make one of them visible according to user selection, right?
Yup. It would be easier to put them next to each other in the designer, and to move them to the correct location when the form is loaded.
Andraw Tang wrote: What did you mean to move it to UserControl?
A UserControl resembles a blank panel, and is used if you need to build your own controls. Imagine that you're using a Panel over and over again to display a picture and the name of the user. You could copy/paste that code and the panel, or you could create a new control;
Public Class MyPanel
Inherits System.Windows.Forms.UserControl
Public Name As String
End Class
This new control can contain anything you like. There's a walkthrough[^] on MSDN if you want to give it a try
I are Troll
|
|
|
|
|
Eddy,
Thanks, I will take a look.
|
|
|
|
|
I'm moving from Ms Access to vb.net/Sql Server. I'm looking for a sample project that includes a vb.net front end and Sql Server back end. There is plenty of sample code out there, but I havn't found any complete applications.
|
|
|
|
|
I'm not sure if you can find complete application, but there are plenty sample codes. What is wrong with sample codes?
|
|
|
|
|
I'm very new to programming, and I'm probably not much of a natural at it, although I enjoy it thoroughly. I learned what I know about Ms Access from "reverse engineering" an application(as well as reading books of course).
I just purchased a book Murach's ado.net vb2008, it has a good amount of sample applications so hopefully it will help.
|
|
|
|
|
soulrebelpd wrote: I learned what I know about Ms Access from "reverse engineering" an application(as well as reading books of course).
I'm not sure how much you can learn from reverse engineering alone. Not to mention the amount of time you will spend in understanding the code.
soulrebelpd wrote: I just purchased a book Murach's ado.net vb2008, it has a good amount of sample applications so hopefully it will help.
Good for you. Books are good source of information. Also consider taking a class. It may accelerate your learning curve.
|
|
|
|
|
|
|
Hi Everybody,
Is there any other process to register dll other than regsvr32 process. If yes please let me know.
Thanks in advance,
Jayachandra
|
|
|
|
|
An actual COM .DLL or a .NET assembly? Are you sure it's a COM-base .DLL? Library .DLL's cannot be registered.
The only other way to do it would be to poke the registry values in by manually, but that's not a good idea at all.
|
|
|
|
|
maybe ...
google this:
programmatically register activex dll
|
|
|
|
|
hello
I'm inheriting a legacy VB COM component - I tried register the component:
regsvr32 SomeMatlabUtil.dll
(The folder contains SomeMatlabUtil.tbl as well in same folder)
But I ran into the error:
SomeMatlabUtil.dll was loaded, but the DllRegisterServer entry point was not found.
We're deploying this on 64 bit WIN2003 machine. Need some help on this...
Thanks
dev
|
|
|
|
|
devvvy wrote: SomeMatlabUtil.dll was loaded, but the DllRegisterServer entry point was not found.
Sorry to state the obvious but if the entry point is not found in the dll then it cannot be registered. I'm not a COM expert so I'm not sure offhand how you get round this, but I'm reasonably certain you can link to unregistered COM dlls.
It's time for a new signature.
|
|
|
|
|
yes very obvious, so how to check if we're missing an attrib to decorate entry point or what? obvious fix/cause?
dev
|
|
|
|
|
As I said, I'm not a COM expert but I would guess you need to look at the source code.
It's time for a new signature.
|
|
|
|
|
Use
Register
[FrameworkPath]\REGASM SomeMatlabUtil.dll /tlb SomeMatlabUtil.tlb
Unregister
[FrameworkPath]\REGASM /unregister SomeMatlabUtil.dll /tlb SomeMatlabUtil.tlb
|
|
|
|
|
Thanks very much guys
dev
|
|
|
|
|
I use to program in VB 6 for many years. I am now trying to move to VB 2010. I want to be able to connect to an ACCESS database, Add a record, delete a record and edit a record with code (no wizards or other controls). Up to this point a can do all this.
The next step is to be able to find a record based on value for any field. In VB6, I use to use a "find" method to find the first record with that search criteria. I could also find the "next" record for that criteria. (This is to find a record, not to filter the table.)
My code so far is:(I have a MDI form with a child form and then a module where I keep my functions.)
In Form:
Private Sub frmDataEntry_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Folder As String
Folder = My.Application.Info.DirectoryPath
MyDatabaseFile = Folder & "\Data\PartInfo.mdb"
mdiMain.Panel1.Text = "My Data Base File: " & MyDatabaseFile
MySQLPart = "SELECT tblPartMaster.PartMaster_ID, tblPartMaster.PartNo, tblPartMaster.Description, " & _
"tblPartMaster.OEM, tblPartMaster.OEMPartNo, tblPartMaster.LastUsed, tblPartMaster.CurrentCost, " & _
"tblPartMaster.DrawingNo, tblPartMaster.Remarks " & _
"FROM(tblPartMaster) " & _
"ORDER BY tblPartMaster.PartNo;"
DataConnect() ' calls a sub in myFunctions module.
DisableText()
ShowCurrentRecord()
End Sub
Public Sub DataConnect()
'*******************************************************
'*** Make Connection
'*******************************************************
MyConnection.ConnectionString = _
"PROVIDER=MSDataShape;" & _
"Data PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & MyDatabaseFile & ";" & _
"Persist Security " & _
"Info=False"
MyConnection.Open()
MyDataAdapter = New OleDb.OleDbDataAdapter(MySQLPart, MyConnection)
MyCommandBuilder = New OleDb.OleDbCommandBuilder(MyDataAdapter)
MyTable_PartInfo.Reset()
MyDataAdapter.Fill(MyTable_PartInfo)
MyTable_PartInfo.PrimaryKey = New DataColumn() {MyTable_PartInfo.Columns("PartMaster_ID")}
MyTable_PartInfo.Columns("PartMaster_ID").AutoIncrement = True
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
If MyRowPosition < (MyTable_PartInfo.Rows.Count - 1) Then
MyRowPosition = MyRowPosition + 1
End If
ShowCurrentRecord()
End Sub
' to add a record
Private Sub btnControl6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnControl6.Click
Dim DataSetNewRow As DataRow = MyTable_PartInfo.NewRow
DataSetNewRow("PartNo") = txtDataEntry1.Text
DataSetNewRow("Description") = txtDataEntry2.Text
DataSetNewRow("OEM") = txtDataEntry3.Text
DataSetNewRow("OEMPartNo") = txtDataEntry4.Text
If IsDate(txtDataEntry5.Text) Then
DataSetNewRow("LastUsed") = txtDataEntry5.Text
Else
DataSetNewRow("LastUsed") = "01/01/1990"
End If
If IsNumeric(txtDataEntry6.Text) Then
DataSetNewRow("CurrentCost") = txtDataEntry5.Text
Else
DataSetNewRow("CurrentCost") = 0
End If
DataSetNewRow("DrawingNo") = txtDataEntry7.Text
DataSetNewRow("Remarks") = txtDataEntry8.Text
MyTable_PartInfo.Rows.Add(DataSetNewRow)
MyDataAdapter.Update(MyTable_PartInfo)
MsgBox("New Record added to the Database")
DisableText()
MyRowPosition = MyTable_PartInfo.Rows.Count - 1
ShowButtons()
ShowCurrentRecord()
End Sub
How to go to a record based on a search criteria. I want to have a textbox where I can type in a "part number" and a "Find" button. So I type in a number and click the button and the form should display the record.
|
|
|
|