Lisbox In A Separate Class File In Vb
Aug 5, 2011I have a listbox in separate class like this [code]
[Code]...
How can I use that list box that I have created in that class on this form or I want to show that listbox on my form?
I have a listbox in separate class like this [code]
[Code]...
How can I use that list box that I have created in that class on this form or I want to show that listbox on my form?
Example:
Two files - TestClass.vb, myForm.vb
TestClass.vb looks as follows:
Imports System.Threading
Public Class TestClass
Private myClassThread As New Thread(AddressOf StartMyClassThread)
[code]....
The result:Application runs, no errors or exceptions.Displayed is the listbox and the Start button.I press the start button and a msgbox says "Not Invoked" as expected and upon clicking OK to that msgbox "Start Button Pressed" is added to the Output listbox control.Immediately following that the msgbox pops up again and says "Not Invoked". I was expecting "Invoked" as a separate thread is trying to use the Output listbox control.Of course this results in the Output.Items.Add being attempted which results in no visible result as the thread is not allowed to directly update the UI control.
How can I move the following to a separate class for repeated use ? (the problem is that it uses response object)
' Download/View a given file
Protected
Sub downloadFile(ByVal sFile
As String)
[code]....
I've made an interface called ApprovalEvent in a separate file with the namespace myproject... I've also made a class called PurchaseOrder... it's also in the same namespace, just in a separate file. Whenever I try to make PurchaseOrder implement ApprovalEvent it always says that ApprovalEvent is undefined...
How can I make the class recognize that the interface exists but is in a different file?[code]...
i would like to have a shared function in a separate class file to address the form location . but i dont know how can i get this to work. if i use this below code in my form its working . but i cannot move this to a class file.
Shared Sub Formlocation()
Me.StartPosition = FormStartPosition.Manual
Me.Location = Screen.GetWorkingArea(Me).Location
End Sub
Can we write all the control events in a seperate class file in different layer rather than in code-behind of web-page ?
View 1 RepliesI have a form with a listbox that when the form is opened I need it to display info from a file. I don't know what would be easier to work with Excel or a txt file, but it is in this format:
Phillip Frank
3/19/1990
3
999-555-8618[code].......
I would like it to populate the list box when the form is loaded, but if I have to use a button to tell it to load that is fine also.On the same form I have 4 textboxes that ask for each of the above items (name, DOB, Level, PH#) and a button that when pushed I want it to save it to the same file where the above info was pulled from in the same format.The Show Contacts button doesn't have to be used if it is not needed.
Good evening folks, I'm building a program that is threaded. While I can get the thread to work no problem, I can not seem to add pages to my tabcontrol from the class I'm using. Any idea's on what I'm doing wrong?frmMain is loaded first. Then the idea is to load the other tabpages using a separate thread as they take awhile.[code]
View 1 RepliesI am having following Projects
ClassLibrary1
Public Class Class1
Public Sub MyMethod()
[code].....
I don't want my application's main form to be displayed when it opens; I just want the notifyicon control in it to show in the taskbar.This is the code I have been using:
Module:
Code:
Module mdlStartup
Public Sub Main()
[Code]...
The NotifyIcon control is in my frmMain. However, when I run my program I get mulitple instances of the Notify Icon being displayed. I even get two frmMains getting launched if I try clicking the other tray icon that has been made. I'm guessing this has to do with the New instance.If that's the problem, is there a way I can move the notifyicon control to some completely separate class?
if there is any method in vb.net to sort a listbox by item length e.gthere is a property in listbox to sort items alphabetically
View 2 RepliesIm trying to get a ComboBox that would list all the pc on a netowrk, (Domain and/or WorkGroup)the idea is so that when i start typing the name of the pc list would come up with sugestions (nearest match)
[code]....
this example shows my problem. I'm using VB.net 2010
Public Class Form1
Public Class BonoType
Public name As String
[Code].....
What happens is "Goose" is not only stored in tory(1) but also in tory1(1), how can I stop this.
I'm writing a program and rather than having all the print properties in the main form I'd like to have them setup in a seperate class. I've done printing before by setting all the properties in the form where all the controls are located with no problems but this has me stumped. Reason for doing this is just to try and organize the program a little better and there are several areas of the program that will have different data and format to print so this will cut down on having potentially hunderds if not a thousand lines in that one area. I can't imaging that this wouldn't be possible.
View 1 RepliesThe code below works fine when I put it in form1.vb and change "form1" to "me" but I can't seem go get it to work from my class.
VB
Imports System.Threading
Public Class Class1
[Code].....
I'm working a business layer (separate assembly) that will contain various business entities used in multiple client applications. One of the client applications is a WCF app that will need to serialize these entities. In order to properly serialize the entities, metadata for data contracts or for XML serialization must be added, but the serialization requirements may vary across applications.
Clearly I need the metadata separated from the class definition. So how do I add metadata to my entities for each separate application?
I need to be able to access a progressbar in my form from a separate class.
I tried
Dim Prog as Progressbar
Public Property Pg()
Get
[Code].....
I need to be able to access a control from a separate thread and return to the thread again.
Edit: Its just an example I gave prog a value of the object from the form and the invoke required is put in a sub so thats not my problem.
I have a class, called myClass.vb. I have a sub in it. this sub has a string variable, which has got some value. Now, i want this value to be transferred to the button_click event of a very seperate form called myForm.vb.
View 3 RepliesI didn't think this would be a problem, but it appears that others also search for this solution. There is an annoying DING! when hitting the Enter key in a ComboBox in VB.Net so I sought solutions. Here is the solution I am working with. I created a new seperate Class within my Project...
Public Class ClasscboBox
Inherits ComboBox
[CODE]...
Looks good, but I am having a problem calling it from the main project. Here is what I have tried using...
Dim objcboBox As New ClasscboBox
objcboBox.OnKeyPress(KeyPressEventArgs)
However, it says thatKeyPressEventArgs is a Type and cannot be used as an Expression. I tried 'e' but no go. I am a little ahead of my classes (no pun intended) so I am likely missing something about what I am doing wrong.
I have three comboboxes so I though this would best suit my needs in the interests of writting decent code and not populating each call with repeating code.
I've been searching for the answer for a while but can't find it yet. Basically so far I have a simple VB.Net form with one button.I would like to make a class or module that can handle events from the main form. This is my code so far but it doesn't seem to work.
View 6 RepliesI am instantiating a form object in my code behind the dataset just to access some form level variables and to occasionally set a label in the navigator bar. Recently in the b2 Team version of VS2010 there are some strange errors thrown in the immediate window and then I'm tossed out of debug mode and back into the IDE. This code has been operating for some time in this project without this behavior. A team member has just reproduced the behavior in his development machine also.The error that starts the shutdown of the debug instance is this: Control accessed from a thread other than the thread it was created on.
View 4 RepliesI've got a simple tool written in VB in VS 2010 that has a series of command buttons which run Windows command files and the output is sent to a Rich textbox object on the main form (the comand files take awhile to run so I wanted the output to show up in the RTB as it was produced to show progress). All worked well until I made an update to the tool so that the series of buttons are no longer hard-coded, but created dynamically from information in the app.config file. To do this, I use a button
[Code]...
I created a telephone number form where the user enters the telephone number in a text box as (nnn) nnn-nnnn. The first 3 digits in parenthesis are the ISD code, the next three are the area code and the last four are the local number. I need to separate out these three fields of the phone number and display in three separate text boxes labeled appropriately. Now, suppose the user enters the phone number in a text box as a continuous string of 10 digits, where the first three represent the ISD code, the next three represent the area code and the last four represent the local number. I'm lost as how to change this string into the form (nnn) nnn-nnnn. This is what I have
[code]...
Anyways, i have coded a video downloaded and i want to include a converter as a separate exe file. But obviously people may have different file directories so a simple piece of code i have used won't work. This is what i have: Also where would i place the exe file?
View 3 RepliesI have a TabControl object on my form with many tabs created in code (TabPages) and my problem is that the same objects that are in the initial TabPage needs to be in the other TabPages created in code, I have this done in code when the user clicks the 'New Tab' menu option, however the same code is used for any new tabs created. The problem created here is that I have an event against one of the objects that appear in the other TabPages, but because the same code is used to create any new tab pages, the event will only work on the newest tab page, if that makes sense? By the way these objects that appear on the other TabPages are properties at the top so events can be handled against them in the respective subroutine.
[Code]...
I'll get straight to my problem - I'm currently coding in Visual Studio.I have a table (countries) with the columns ID | Name. The table is filled with around 28 records.I also have a form with 4 combo boxes (set up as 1,2,3 & 4) that I want the user to select. These combo boxes will display the names from the table countries. I then want to use the selected names in the combo boxes to Insert into their corresponding ID into another table. For example England would have the ID 1, USA the ID 2 etc.So, is it possible to have separate combo boxes that will give separate ID values but using the same table? At the moment I can't seem to find a solution.Eventually the form will have more than 4 combo boxes so I don't want to use separate bindingsources for each combo box.
View 5 RepliesI have a class (see below)
Imports Microsoft.VisualBasic
Imports System.Data.SqlClient
Public Class ClientProfile
#Region "Variables"
[CODE]...
It is in the file ClientProfile I have placed in both App_Code and also App_Code/Models
In my code behind I have the following
[CODE]...
The last word, "ClientProfile" has the scary squiggly red line below it. It is not recognizing my class.Even the Intellisense is not picking up te class. Do I have to register the class file in any way?
I have a search page with a couple of pulldowns. Dependig on the values of them I show a grid matching the searched criteria, basically a table with links the user can navigate to. My problem comes when the user wants to navigate back. At the moment I have a "Back" button which simply redirects the user to the initial search page. I think it would be a good improvement to have the values of the pulldowns filled in with the values the user selected, this way when he presses the "Back" button he would not have to restart the whole search process again.
View 5 RepliesAfter creating a project in vb.net how to make a separate file so that by clicking on the file the project should directly execute
View 4 RepliesI am playing around with VB 2010, and I want to create a separate file with different procedures etc so that I can call a proceedure etc from this file I have a simple form with a single label on it, and a seperate file called filelib.vb.In the filelib.vb is a proceedure called LogicalDriveTypes
Public Function QueryLogicalDriversNames() As String()
Try
Dim Totalstring As String
Dim ds As Int32
[code]....
In my form1_load I have Label1.Text = filelib.LogicalDriveTypes and I get "reference to a non-shared memner requires object reference. How where / what do I do to access the proceedures / functions in this other file any time I need to from this form ?