Addressing And Reading A Control On A Form From A Module

May 7, 2012

I simply cannot refer to a control on a form from module code as in all other versions of VB. Here is the code that I mean:[code]The fact that this cannot seemingly be done without getting into looping through an array of controls, assigning the control to a general control variable etc. and much more guff is puzzling and is in my opinion an added complexity to Visual Basic. There must be a simple way to do this - I just want to refer to the value in a control, on a form, from a module.

View 13 Replies


ADVERTISEMENT

Control Form From Module?

Jun 20, 2012

I recently have convert my project from VB6 to VB.NET2008,after the convert here is a sub that control form from a module that i create,the error was something like

"cmdAdd is not a member of System.Windows.Forms.Form"
Public Sub ButtonSet(ByRef frmObj As System.Windows.Forms.Form)
frmObj.cmdAdd.Visible = True
frmObj.cmdCopy.Visible = True
frmObj.cmdEdit.Visible = True

[Code]...

View 1 Replies

Use Instance Or Form Name When Addressing Public Variables Between Forms?

Nov 17, 2009

In vb.net, you can address a public variable from another form using the form name along with the variable.

form2.show
form2.k = 3

However, if you use a form variable to show an instance of the form, you must use that variable name to address the public variable. Two instances of the same form are displayed in the following example. The public variable k is assigned a value of 3 only in the first instance of the form, the one from form2.show. frm.k can be used to assign a value to the other form.

dim frm as new form2
form2.show
frm.show
form2.k = 3

Assuming only one instance of the form is shown in the application, is it reliable to address a public variable using the form name (form2.k), or is it better to show the form with a form variable and use that to refer to the instance of the form (frm.k)? Would the same answer apply to a property as well as a public variable?

View 2 Replies

Refering To A Form Control Property From A Module Function / Sub?

Mar 7, 2012

I have a single form application with two modules. The first module holds all the Sub procedures that provide the filtering functionality for 3 DataGridViews on the form. The second module holds the Predicate of T functions that actually filter the List(Of T) objects that are bound to the DataGridView controls.

I split them into modules since I was starting to have difficulty organising and finding the procedures and functions if I held them all in the form code.In some cases I can happily both Get and Set form control properties from within the modules. In one case I simply can't, I suspect I may yet find some more instances as I test further. The offending line is in one of the Predicate of T functions:

If tWord.Length <= Investigator.NumericUpDown.Value Then Investigator is the Class name of the form.

I suspect my problem might be that the Predicate of T functions (which are collated in a module) are called from the DoWork procedure of a BackgroundWorker that is a component of the form - hence the DoWork procedure is in the form code, but I'm not certain. The same code worked fine when everything was all in the form code. The error reported when adding a watch to the Value property in the module function is "
'Value' is not declared. It may be inaccessible due to its protection level ". I have tried the following to no avail:

1) Setting the NumerciUpDown modifier to Public

2) Adding a Public ReadOnly Property to the form class that simply returns the Value propety of the NumericUpDown

3) Adding Imports Root Namespace.Investigator to the module

I am considering adding a Public Shared variable to hold the curent value of the NumericUpDown and referencing that from the Predicate of T function.I realise, and have read many times, that accessing form control properties from module functions is generally not seen as a smart thing to be doing, but since I am not trying to chnage anything, I simply want to know what the current value is I decided that I wasn't too worried.

View 11 Replies

Cross Thread Error Reading Form Control

Mar 17, 2011

I'm learning VB.NET coming from a VB6 and Java background.In my app, I've got a function that validates the fields on a form. All it is doing is reading them, not updating. I've searched and see info about the backgroundWorker class, but all the examples are about updating the fields.I understand the idea of threading and how it works, but have never written code that spawned threads myself. I've always let the language handle it. It seems like a lot of work that I would have to write a sub using the backgroundWorker for every time I wanted to read or update each field. The couple of books I've got that introduce you to the language show you reading or updating the field directly.How do I know what threads are running other than writing the code like I'm used to then running through debugger to figure out what variables are on which thread?

View 2 Replies

Reading Data From Arduino Bluetooth Module

Jun 30, 2010

How to read in data from an arduino bluetooth microcontroller? I am new to microcontrollers and I have limited VB experience. The arduino is currently outputting some data to the arduino software screen. I have opened the COM port for the arduino in VB but am unsure how to get the data into a VB string.

View 3 Replies

Addressing Pixels In A Bmp?

May 25, 2010

I would like to believe that this code will display a horizontal line halfway across the PictureBox pbxData. In fact, what it does is create the BitMap and then blow up with a memory violation when trying to copy the BitMap into the PictureBox. The code that alters the array is commented out because I don't know how to address the elements of the array.

how to make this into useful code?

Imports System.Runtime.InteropServices
Public Class Form1
Private b1 As Bitmap

[Code].....

View 13 Replies

Resources Addressing By String?

Sep 21, 2009

I have several images in my My.Resources i wish to load the images into a user controle i wish to change the image loaded into the card control at each pass of the for net loop to make my own deck. but i can not change pdeck(c).face = CType( My.Resources.he10, System.Drawing.Image)

[Code]...

View 2 Replies

Call A Variable Without Addressing It Directly?

Jul 10, 2011

So I am having an issue where I want to call a variable without addressing it directly and I get an error for it:

Conversion from string "player1BuzzLock" to type 'Boolean' is not valid.

This is technically correct but why would it fail?

Dim player1BuzzLock As Boolean = False
Dim PlayerNum as Integer = 1
'...
Dim playerBuzzLock As Boolean = CType("player" & PlayerNum.ToString & "BuzzLock", Boolean)

View 13 Replies

Create A Control Class Rather Than Use A Module For MVC?

Mar 20, 2012

I'm trying to use it in writing VB.NET Windows Form code.So I'm thinking, instead of using a VB.NET module, or having code embedded in the forms, I should create my own "Control" Class, to handle all operations and "application" level variables.Is this the right approach?Ex:

Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
goControl = New MyControlClass()
goControl.sUserID = txtUser.text[code]....

View 1 Replies

Database - Reference A Control From A Module?

Jan 30, 2010

I have a MS Access database set up, with a Period field that has either values 1, 2, 3, 4 or 5. I retrieve these values using a database connection and I would like to reference a particular control based on what period was grabbed from the database.

Here's example code, pseudo of course.

TextBox(dr(3)).Text = dr(0)

dr(3) contains the period, and dr(0) contains the content I would like to put into the text box. I have these text boxes on my form: TextBox1, TextBox2, TextBox3, TextBox4 and TextBox5.So if dr(3) contained 2 then I would want to reference TextBox2.

View 2 Replies

Define Control Within A Tab Page From A Module?

Dec 1, 2009

i am currently building a MDI application. Both my Add and Edit screen use a form called frmStaffDetails.

On load, this form is redefined as 'AddStaffChild' and 'EditStaffChild' dependant on which menu item is selected. I've defined the CurrentForm as Form.ActiveForm.ActiveMdiChild.

Within a module I am checking the text within certain textboxes. So for example here I am checking a name has been inputted. If it has, then I will allow the record to be saved.

[Code]...

The problem I am having is that this code works perfectly if the textbox control is not within a Tab Control. As soon as I put it in a tab page I get the error.

"Referenced object item has a value of Nothing" Also if I reference it directly for example

If Not AddStaffChildForm.txtFirstName.Text this works fine too, but i want it to be more genric so I can use it for my edit screen as well. How can I define a control within a Tab Control from a module (or any other way to declare a public sub).

View 3 Replies

Forms Control For Availability Module?

Apr 12, 2012

I'm building a apps that which allow to check the room availability for a hostel.I am looking some controls which is similiar to the following which allowed me to change the color of the box during runtime.

View 10 Replies

.net - Finding Out Which Instance Of A Form Initiated Another Form Or Module

Oct 5, 2010

I'm trying to figure out the best way to reference a control on a form from within a module. Unfortunately the form is just an instance, so it's not as easy as calling form.control...

Dim ChildForm As New frmSearch
' Make it a child of this MDI form before showing it. '
ChildForm.MdiParent = Me
ChildForm.Show()

That form has an option for printing, which calls another form where certain options are chosen. The print form in turn calls a function in a module, which tries to reference back to the origional form.

childform as new frmSearch -> frmPrintForm -> sub okToPrint (in module Print)
okToPrint tries to reference a listview on frmSearch, but can't find it.
For Each itmX In frmSearch.lstResults.Items

So the solutions I can think of off the top of my head are:

1. Somehow divine which form is the caller of frmPrintForm

2. Pass ChildForm to the frmPrintForm as a variable to be passed on to module Print..

3. Use frmSearch directly instead of using an instance of it.

Number 1 would be my preference, as I don't want to have to pass forms around like that.

View 4 Replies

Addressing Individual Monitors In Dual Screen?

Jul 8, 2009

I am working on a custom bulletin board system for my company. The idea is to have a program running that displays a full screen bulletin board on many monitors around our facility. I wrote a VB client that pulls from a server and displays a single board perfectly - I am wondering how to expand this.

View 10 Replies

Background Worker - Addressing Richard Cloete?

Sep 25, 2010

recent thread, there was a passing discussion regarding running Rick's program in a background worker in order to keep the user interface "alive". The thread was actually about memory usage, so I decided to put this together instead.First, I'm sure no expert at any of this, so do take all of this "as is" and with a healthy dose of skepticismThebackground worker is a fairly easy way to let your program run time-consuming or complex operations on another thread so that your main thread (your user interface) stays active. This can be done other ways of course, but the BGW has many things builtinto it that makes it ideal to use for just this sort of thing.

One caveat to keep in mind is this: You cannot directly "talk" from the BGW to your main thread or you'll get a cross thread violation exception. As an example, you cannot set a label's text value (on the form, thus on your main thread) from the BGW, butyou can modify class-level variables then in the BGW's Progress Changed event, it will update that text based on the variable.In this example I'm doing this two ways: The first is a calculation of the percentage done (so that I can display it textually and in the progress bar), and the other is text indicating the status.

View 12 Replies

Access A CheckBoxList Control In A DotNetNuke Module?

Mar 17, 2010

I have a dynamically created CheckBoxList in a DotNetNuke module I'm building. When DNN creates the page, it prepends the control name with the moduleID and moduleName.

So, when I have "AddLicenseCheckBoxList" on the page, it becomes:

"dnn_ctr949_addRateGroup_AddLicenseCheckBoxList" depending on what the ModuleID and page name is (in this instance it's 949 and addRateGroup respectively). Now, I don't know what the name of the page or moduleID will be when this module is finished, so I need to make sure I am accessing the control my whateer name DNN gives it, and getElementById or getElementByName do not work even when using '<%= %>'.

So what I need to do is use Javascript or some VB to retrieve the checked values of the dynamically created CheckBoxList so that I can run an update on the database with those selected values. [code]...

View 2 Replies

Can't Find A Media Player Control Or Module

Oct 29, 2009

I can't find a media player control or module. I'm using the Express Edition does it even have one?

View 8 Replies

How To Access WebBrowser Control In Forms From Module

Jan 3, 2012

I am trying to access a browser control in one of my forms from a module but keep getting an error. I attached a screen capture showing the code and the error balloon. The subroutine is public, and I am addressing the browser correctly. If I copy that same code into the "Main" form, and it works perfectly.

View 3 Replies

Update A WPF Control From A Background Thread From A Module?

Jul 2, 2011

My application has a total of 1 form. I have several modules, one of which is a module that handles a background worker dynamically. But what I need to be able to do is update a textbox from the background worker thread. Again, this code is contained within a module, not directly on the main form, so I am totally clueless as to how to make a reference to it. It's easy in WinForms, but I can't for the life of me figure out how to do it in WPF...

View 4 Replies

Create A (in Excel ) Variable Table (database) Inside A Function Which Could Be Called For Filling And Reading Through "for To Next" Loop Module?

Feb 4, 2012

i just got 1 question how do u create a (in excel ) variable table (database) inside a function which could be called for filling and reading through "for to next" loop module

View 2 Replies

Get Form Name In Other Module?

Jun 18, 2012

I have a connection module in which I have written the open and close database connection.... if database connection is an error it will return false else if success it will return true the function of the modules will be called from the form code....

what I need is if the connection is an error the module should also get the form name which returned the error...is it possible???

check my below code....

DBConnection.module
Imports System.Data.SqlClient
Module DBConnection

[Code].....

now what I need is if the functions Open_DB_Connection() or Close_DB_Connection() returns error it should prompt the form name....

View 4 Replies

Editing A Form Through A Module?

Jul 14, 2009

How can I edit my a form through a module? I am using this code in the module.

Here is where I get an error: Private Sub ExtendedWebBrowser_NewWindowExtended(ByVal sender As Object, ByVal e As WebBrowserNewWindowExtendedEventArgs) Handles Me.NewWindowExtended Button1.Text = "New window event just triggered!"End Sub

The code editor will not recognize when I type Form1, and I obtain the following error when I manually type it:form1' is not declared.I sense there is something I can do here which is very easy to fix this, but I have not worked much with Classes before.

View 2 Replies

How To Refersh A Form From Module

Jul 22, 2011

he form has a listview control. The form call a function stored in a module VB file. In the function, I will do something. I want to add a monitor in the function. When finish somethings, the function will add some message to the

View 1 Replies

Notify A Form Sub From Module?

Nov 21, 2010

I am writing a program in VB2010 Express that handles serial port communication. All subs and functions that handle writing to, and reading from the serial port are in a module. These subs and functions are typically called from a form, e.g. by pressing a button. The command is then sent to a device attached to the serial port, and this device replies with a number of bytes as a result. A 'ReceivedDataHandler' is used to handle the serialport.datareceived event. [code]....

View 6 Replies

Refersh A Form From Module?

Dec 14, 2011

I have a form. The form has a listview control. The form call a function stored in a module VB file. In the function, I will do something. I want to add a monitor in the function. When finish somethings, the function will add some message to the listview. I add the form.refresh event at the after listview add item coding. But, it doesn't work.

View 6 Replies

Show Form In Module?

Sep 17, 2009

Just want to ask something, how can i show form in my Module?

View 2 Replies

VS 2005 - How To Add Module To Form

Jul 4, 2009

How to add Module to Form in VB 2005?

View 2 Replies

Access Form Controls From Module?

Apr 23, 2011

How do I do something like this.[code]...

This is inside the Module separate from Form1 class as you can see right off the bat it's not a class and there is no reference to Form1.. how do I access Form1 without passing reference to make factory modules work like this.

View 1 Replies

Call A Sub Defined In A Form From A Module?

Jun 20, 2011

i've created a Sub in a Form.

I've created another Sub in a module.

I call the Sub in the module from the form, passing the form into the Sub defined in the module.

Then i add an Handler to an istance of a control (for example mousemove) and i want to give to this handler the execution of the Sub defined in the form.

Example.

Class form1
Sub Form1Sub()
ModuleSub(me)

[Code]....

The problem is that i don't know hot to call the Sub defined in the form, in the Sub handler using the istance of the form passed in the Sub paramenter in the module...

View 7 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved