Threaded Sub-Procedure Within A Module Not Obtaining Correct Data From Other Form?
Feb 3, 2012
I have an ArrayList that is set to Friend. Once I click my button "abc" is added to the ArrayList and then the form MsgBoxes out the Count of 1 (Correct).When I use Threadpool to count the number of objects within the ArrayList it always returns 0.
Example:
Imports System.Threading
Public Class Form1
Friend Alphabet As New ArrayList
[code]....
I am obviously getting some sort of cross-thread issue here but have no idea how to correct this. I usually just setup single threads so this is my first time playing with ThreadPool & already lost at step 1!
View 1 Replies
ADVERTISEMENT
Mar 4, 2010
How do I pass a variable to a threaded procedure? The clickedItem.Tag contains a username as a string which I want to pass to Public Sub GetLockoutInfo(ByVal UserID As String) but the AddressOf GetLockoutInfo line doesn't allow for a parameter to be passed to the procedure.
Private Sub CallGetLockoutStatus(ByVal sender As Object, ByVal e As System.EventArgs)
Dim SearchUserDetails As New NiRDs_Functions_OC
[Code].....
View 2 Replies
Aug 6, 2011
I would love to use the following procedure to set the Title, keywords etc. of my pages, in a module.
Public Shared Sub SetTitle(ByVal Heading As String, ByVal Keywords As String())
Dim myMaster As Masterpage = DirectCast(Me.Master, Masterpage)
If Request.QueryString("lng") = "es" Then
[Code]....
The problem is that i get two errors.
At Me.Master i get the 'Me' is valid only within an instance method. error and at
If Request... i get the error
Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
So how do i fix these? I would like to have that procedure in a common place and not in every page.
View 1 Replies
Dec 16, 2010
I've been coding a Windows applicaton for the past seven months but there aren't a lot of "windows" in the application so I have a question on getting and returning data from forms. I display a form and the user makes a listbox selection then presses Ok. Normally I can proceed from there (in a class module) with values from the config file, but sometimes his selection will require me to ask for more information. So I want the class to display a form, pass control to it, then when the user hits OK on this form, return to the class. What is happening is the class continues with all its inline code and function calls and doesn't show the form until the end of its current function.
Dim flClientInputFile As New CFile
Dim flPreparedOutputFile As New CFile
Dim lRecordCount As Long
Dim sProcessing As String
Dim sTest As String
Dim frmAbc As New frmAbc
frmAbc.Show()
frmAbc.Activate()
x()
When I run and step through this code, I find I'm in x() before I even saw the form. x() needs the data the user has entered on frmAbc in order to continue.
View 2 Replies
Jan 22, 2011
What is the best way to go about retrieving data from a proprietary hardware device that interfaces via HID USB? The particular device I need the data from is a blood-pressure/heartbeat measurement & monitoring device.The hardware came with software that downloads the data from the device and places that data into a (passworded/encrypted) MS Access database that I cannot connect to using programmatic methods, at least not without having the (admin's) password. The software provided produces reports, but the formatting renders them virtually useless (well, completely useless) for the needs of our company.
The device manufacturer provides to it's customers no API or any other technical information for accessing the data produced by their product; so, this pretty much leaves me stuck trying to figure out how to obtain the data via custom application in order to reclaim the initial justification for the expense associated with the hardware, which by the way has already been purchased.I don't need code snippits specifically, though examples would be nice; what I really need is to know is how to best approach this project, from a general design and programming stand-point.
View 2 Replies
Feb 2, 2009
How I would use a search procedure for a text changed event to look at a structure in module.
View 2 Replies
Apr 11, 2011
i created a threaded form class that i call when i know an update is going to take a while....it is a simple form with a label and an animated marquee progress control. the code is listed at the bottom....whenever i try to set the message, it says i cant do it with error "{System.InvalidOperationException: Cross-thread operation not valid: Control 'MessageLabel' accessed from a thread other than the thread it was created on." from my form (in my SAVE function, i put the following line:[code]....
View 6 Replies
Jun 7, 2011
What is the VB2010 mechanism for obtaining a form's handle?
View 1 Replies
Jun 23, 2011
im trying to make a project that obtain data from a text file and place records into a SQL server DB (.mdf).
basically i ve created my database, its ready but the thing is i dont know how to retrieve data from text file and put the records into DB
View 5 Replies
May 17, 2011
I am usng a multi threaded process to fire off a task, but when it is completed I want to make a label visible on the main form (form 1), eg "process completed", however the code I have in place comes up with the following error message;
Cross-thread operation not valid: Control 'lblCompleted' accessed from a thread other than the thread it was created on.
View 4 Replies
Dec 14, 2009
I have an app that I'm trying to keep single threaded, mostly for reasons to do with simplicity of ongoing maintenance. I've structured it so that I can eventually multi-thread it if need be but I'd rather not at this point. It's semi-real time and does perpetual looping to display a number of different graphs and do various work with both the graph display and the work being hosted in their own respective objects. If you're familiar with the Windows dispatch manager it's that general paradigm run synchronously. And yee haw, it pretty much works at this point and runs fast enough to meet requirements by a happy margin. I have a cosmetic problem that I'd like to solve if I could. When I left-click and move any form around, my graphs stop updating until I release the left click button. I was thinking about a doevents somewhere in the click event catalog.
View 1 Replies
Jun 22, 2010
I have an Excel based algo-trading app that needs to take in lots of real-time data, and make trading decisions based on the calculations driven by the data. It is not one of those "read-only" stock ticker kinda spreadsheets.I created a COM object with VB.NET that runs in its own thread space which collects data from a socket, and when the data is read it raises an Event with data attached. In Excel VBA, the event handler parses the data, puts them to the right places on the spreadsheet to feed calculations (so far it sounds like a stock ticker app), and then, based on the results of the various calculations it does something.The problem is that when the user starts to click around the spreadsheet while there is large amount of data coming, the event handler's cell updating breaks apart. If the app is left alone without user action, it stands well. My frustration comes from not understanding what happens to the main thread when a user clicks around. Either the event handler blocks the user action, or the user action blocks the event handler (under which case I will put in some queuing facility). But I just don't see how user action can break the code (like causing VBA to stop executing)
View 9 Replies
Feb 27, 2009
I am trying have a data grid selection populate a form. I am new to this.Basically I have a connection persistance object and I would like to call that and call a stored procedure with the value of the selection. The datagrid is bound to an object.
[Code]...
View 1 Replies
Jun 28, 2009
I am using Visual Basic express to create a serial interface to a multi-room audio controller. I have started by creating a form that can connect to the controller and I can receive data from the Controller and display Zone status, volume etc in corresponding texts box thaks to help from Stanav and Tassa in my previous thread.
My next problem is to do with receiving lots of data from the serial port and my application getting out of sync. This is mainly caused by turning the volum control as each time it is turned a little bit the controller sends out the new status of the Zone being effected
eg
****Turning Volume knob on Zone 1***
Status returned from Controller:
#Z01PWRON,SRC3,VOL05<CR>
[Code].....
View 7 Replies
Apr 16, 2012
CODE:
That code works to read the entry data and to recognise the correct data, and the incorrect. However, even if entry is correct, the error msgbox will appear (x times of how many records there are in file), despite being navigated to the menu. Anyway that the Else isn't triggered when data is correct. Also for it to appear just one instead of (x times of how many records there are in file.)
View 2 Replies
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
Jul 18, 2012
im having a problem on my sql command. here is my command
select ProductCode, ProductName, qtyinstock, critical
from product where qtyinstock <= critical
[code].....
View 3 Replies
Mar 23, 2011
In VB.NET I've got two forms, on first one I have button, on second - two textboxes and "OK" button. I want to run procedure (Sub) on first form, then stop in the middle of it and wait for input on the second form. After that i want to process the data received from second form.
It looks something like this:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Open form2 for input
[CODE]...
The question is how to call the Form2 so that procedure is stoped till the second form is closed?
View 3 Replies
Apr 10, 2009
I am a bit confused on the correct way of opening a form. I generally practiced form1.show to open a form, but i came across the following code to open an form.[code]....
View 9 Replies
Jul 30, 2011
[VB 2008]. I'm trying to populate a DataGridView based on information in the Items in a ListBox (specifically, the file names without hypens or file extensions) and the content of the actual files. The DataGridView is supposed to look something like this:
IDNon-Hyphenated File NameFile Data
1. Some fileThe sky is blue.
2. Another fileThe grass is green.
The Items in the ListBox (lstFiles) look like this:
C:UsersUsernameDesktopFolderAsome-file.txt
C:UsersUsernameDesktopFolderAanother-file.txt
What is happening is that the DataGridView is being populated, but it looks like this:
IDNon-Hyphenated File NameFile Data
1 Another fileThe grass is green.
2 Another fileThe grass is green.
It's adding the second file's information to the DataTable twice and not adding the first file's information at all.
Private Sub btnDoSomething_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnDoSomething.Click
Dim pattern As String = "([w:\w /]([a-zA-Z0-9-]+?).w+)"
Dim reg As Regex = New Regex(pattern, RegexOptions.IgnoreCase)
Dim mat As Match
For Each Item In lstFiles.Items
[Code] .....
View 5 Replies
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
Nov 9, 2010
I just have not been able to find the correct syntax for refreshing my form. The Labels are added to a shape container and I delete them from it as well. All code seems to work only there is a ghost of the label left behind.
View 1 Replies
Mar 11, 2009
I did move the form to the top position of the screen but it doesn't move on the correct position. [Code] form1 supposed to be on the top of the left of the screen. but it doesn't at the top screen but every time i click open button, form1 keep on moving downward.
View 3 Replies
Jun 2, 2009
I've inherited some code that has a Public Module for data access:
[Code]...
And all the pages call GetDataSet(sql). Am I correct is assuming that this is a bad idea? Worst case is that concurrent callers could get each others data?
View 4 Replies
Mar 17, 2009
I'm basically trying to send a string that I make in a module to a textbox on a form.[code...]
View 2 Replies
Jan 31, 2012
I'm trying to read data from a text file into an array and then loop through all the lines and display it into the textbox, only problem is i want each line on a new line so this is what i have:
[code]...
But that adds a newline to that last line causing a out of bounds error.How do i make it add a newline for each LINE except the last one?
View 5 Replies
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
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
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
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