Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB.NET
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 23rd, 2008, 01:11 AM
Registered User
Join Date: Jun 2008
Location: Kuala Lumpur, Selangor, Malaysia.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Gini
Default Query about code

The code below is for the combo box to retrieve items from the database. But now the problem I face is in the

Friend WithEvents CatCodeComboBox As System.Windows.Forms.ComboBox.(from the code).

For the

Friend WithEvents CatCodeComboBox As System.Windows.Forms.ComboBox,

the error is 'CatCodeComboBox is already declared as 'FriendWithEvents CatCodeComboBox As System.Windows.Forms.ComboBox' in this class. I do not know why this error has popped up and how do I solve it?

Imports System.Windows.Forms.DataGrid

Imports System.Data

Imports System.Data.SqlClient

Public Class InventoryMainForm

Private CatCodeDesc As String

Private CatCode As String

Private WarehouseLocation As String

Private Warehouse As String

Private UOMCode As String

Private subcatcode As String

Private subcat1code As String

Private subcat2code As String

Private subcat3code As String

Private AddNew As Boolean

Dim DQcheck As New SqlCommand

Dim DHcheck As New SqlDataAdapter

Dim DScheck As New DataSet

Dim Dvcheck As New DataView



'Declare CatCodeComboBox as combo box

Friend WithEvents CatCodeComboBox As System.Windows.Forms.ComboBox

' This method initializes the combo box in Item Category Level 1, 

' adding data from the table inv_category but limiting the drop-down size 

' to six rows so the combo box doesn't cover other controls when it expands.

Private Sub InitializeComboBox()

Me.CatCodeComboBox = New System.Windows.Forms.ComboBox

Dim connString As String = "server =;" + "integrated security = SSPI;" + "database = LBB"

Dim conn As New SqlConnection(connString)

Dim strSQL As String = "SELECT ict_code FROM inv_itemcategory"

Dim da As New SqlDataAdapter(strSQL, conn)

Dim ds As New DataSet

da.Fill(ds, "inv_itemcategory")

With CatCodeComboBox

.DataSource = ds.Tables("inv_itemcategory")

.DisplayMember = "ict_code"

.ValueMember = "ict_code"

.SelectedIndex = 0

End With

Me.CatCodeComboBox.Location = New System.Drawing.Point(95, 32)

Me.CatCodeComboBox.MaxDropDownItems = 5

Me.CatCodeComboBox.DropDownStyle = ComboBoxStyle.DropDown

Me.CatCodeComboBox.Name = "CatCodeComboBox"

Me.CatCodeComboBox.Size = New System.Drawing.Size(292, 21)

Me.CatCodeComboBox.TabIndex = 0


End Sub
Reply With Quote
  #2 (permalink)  
Old June 23rd, 2008, 09:58 AM
Friend of Wrox
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts

Search for all occurences of "Friend WithEvents CatCodeComboBox" You can only have one instance of that statement. Check every box that will cause the search to include more areas: whole project, include hidden text, etc.

This statement should be generated by the form designer. If you are adding this statement through other means, you are going to run into troubles (even if you didn't set out to do that).
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop Down List Code Query rsm42 ASP.NET 1.0 and 1.1 Basics 1 July 4th, 2007 02:22 PM
Code Query rsm42 ASP.NET 1.0 and 1.1 Basics 3 April 16th, 2007 12:06 PM
code for insert query shabirmaher General .NET 1 August 8th, 2005 08:20 AM
code to copy a query recordset to a file Ivan Access VBA 9 October 31st, 2003 06:50 PM
Select Query Code stevewardau Access 4 July 9th, 2003 01:14 AM

All times are GMT -4. The time now is 07:25 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.