Pass A Form As A Parameter In A Function/Sub?

Mar 23, 2010

Can I pass a form as a parameter in a sub like public Sub GetData(Byval Frm as form) and access its controls?I have few forms (you can say: FrmAccounting, FrmEngineering, FrmIT) with almost the same controls in each of them (txtEmployeeID, txtEmployeeName, optMale, optFemale etc), where no two forms are open at same time, and each of those forms have a Button which opens a new Form (you can say FrmCollectData) now I want to fetch data in FrmCollectData depending on which form it was opened from.. like if user was on FrmEngineering and it clicks button to open FrmCollectData.. form collectData fetches data from FrmEngineering Controls and if user was on FrmAccounting and it opens FrmCollectData, form Collectdata fetches data from FrmAccounting..

earlier, in VB6.. In one of the Sub written in frmCollectData I checked which form is opened by setting flags in each of forms (frmEngineering, frmAccounting etc) and then I passed the same form in a sub which writes data in frmCollectData controls.. but am not able to do the same in VB.NET.

View 5 Replies


ADVERTISEMENT

Pass Function (Of TElement / TKey) As A Function Parameter

May 28, 2012

I want to make a GetAllContacts method which takes a sort parameter of type Func(Of Contact, TKey) which is the same type that the OrderBy method for an IEnumerable(Of Contact) takes.[code]"Too many arguments to extension method 'Public Function ElementAtOrDefault(index As Integer) As Contact' defined in 'System.Linq.Enumerable'." on the second parameter.

View 2 Replies

How To Pass Parameter For Function

Dec 9, 2009

I have a statement:
dat.XoaNhanVien(Me.dtgcapnhatthongtin.CurrentRow.Cells(1).Value, message)
That is a function for deleting info. Now I want to create other function and get above function to parameter. I mean:
Public Function func(Byval func as " What type can be ?")

View 13 Replies

Pass Array To Function As Parameter?

Dec 7, 2010

I would like to pass array to function as parameter. Here is an example for variable that is not array:

[Code]...

View 5 Replies

Pass Control As A Parameter To A Function?

May 27, 2009

i am designing an application in which contents of an excel file are displayed in the ListBox. i have created a class which contains methods for doing this. Statement used for function call is:

oSheet = obj.displayColumns(oWB,
Me.lbColumnNames)

[Code].....

line where i am getting error is underlined. Is it possible to send controls as a parameter ?

View 5 Replies

C# - Pass An Anonymous Type As A Parameter To A Function?

Aug 1, 2011

After reading this post i realized that i cannot pass an anonymous type as a parameter to a function. So what other options do i have?

Perhaps, passing a Query.ToList as parameter would help, or am i re-inventing the wheel?

Update: I have the following query, which i would like to pass to a function:

Sub Test
Dim Query = (From c In DB Select New With { .ElementName = c.Name })
DoSomething(Query)

[Code].....

View 3 Replies

Pass Radio Button Parameter To Another Function?

Oct 31, 2011

I have 2 functions, one is SaveData() and the other is SendEmail()

in the SaveData() the radio buttons that are selected are saved, and the SendMail() is called at the end.

in the SendMail() the radio buttons are "tested" and then one of two emails is sent out based on the radio choices.

The problem I am having is passing the parameters correctly. I have tried several different method but the parameters are not being sent to SendMail()[code]...

View 1 Replies

Asp.net - Pass Parameter As Text To JavaScript Function From .NET Code-behind

Mar 23, 2010

Basically, I have a gridview that is opened in a new window from the parent window. It has a bunch of records with a view button to view the details of each record (which stays in the same newly opened window). I have a calendar in the parent window that accepts a Date querystring parameter to set the current date on the calendar at page load. I'm just trying to refresh the calendar in the parent window to match the date of the label in the newly opened window.

All the code below is in the newly opened window. The .Net code-behind below refers to when that view button is clicked and everything is populated. At the end, I call the js to refresh the parent window and pass the value of the LabelScheduleDate as the querystring parameter. Now the label comes through as '03/25/2010' in the code-behind, but when I pass it to the js, it comes through as '0.00005970149253731343' in the end querystring. I'm not really sure what is making the value change, and I want to pass it as just text. Do I need to pass it as a string object? I tried but I don't think I was doing it right.

JavaScript Function
function RefreshParent(inputDate) {
window.opener.location = window.opener.location + "?Date=" + inputDate;
}

[Code]....

View 1 Replies

Pass A Parameter From The Select List Into A Function For Joining A Linq Query?

May 25, 2010

I have a query that can be summarised in SQL as follows;

Select
S.StockCode
From
StockToCheck As S

[Code]....

Where the S var is a list of strings. This gives the error 'S' is not declared and points to the S in the function call / join (GetPOSStock). So it does not seem possible to do this in Linq, can anyone confirm?

View 1 Replies

Sqlite - Loop Through Selected Records And Pass Each Record As A Parameter To Another Function?

Jun 5, 2010

I have a sqlite table with following fields:

Langauge level hours
German 2 50
French 3 40
English 1 60

[code]....

I want to loop through the records based on language and other conditions and then pass the current selected record to a different function.So I have the following mixture of actual code and psudo code. I need help with converting the psudo code to actual code, please. I am finding it difficult to do so.

Here is what I have:

Private sub mainp()
Dim oslcConnection As New SQLite.SQLiteConnection
Dim oslcCommand As SQLite.SQLiteCommand
Dim langs() As String = {"German", "French", "English"}

[code]....

View 3 Replies

Pass Parameter To Read It On New Form

Mar 2, 2012

From a button located to a new form i am trying to open another form using
Manage_groups.ShowDialog()
That works fine, but now I need to pass a parameter in order to read it on the new form but
Manage_groups.ShowDialog(thisbutton.Text) it's giving me error
Unable to cast object of type 'System.String' to type 'System.Windows.Forms.IWin32Window'.

View 3 Replies

VS 2010 Pass A Parameter To A Form

May 13, 2011

When the user clicks on a control on my form I want to open or show another form and display some properties of the control that was clicked. I want to use the same form to display the properties of several controls, based on which one was clicked. I am not sure how to approach this, can someone point me in the right direction?

View 8 Replies

Pass Parameter To A Dataset Query (.net Form App)

Jun 10, 2011

how to pass a parameter to a predefined parameter in a dataset. I've found everywhere a solution if you build the sqldata adapter and the dataset in the code. Then you can pass the parameter like: da.SelectCommand.Parameters.Add("@param1", SqlDbType.Char).Value = param1_variable (as example)

But if you have builded a dataset (with table adapters), and then in the form app you want just to pass the param1 to a DataGridView1 (as example) which is using the table adapter, I did not find how to do this.

View 2 Replies

Pass Parameter From .NET Windows Form To Cyrstal Report Viewer?

Sep 10, 2010

FormA contain a textbox for user to enter their name and a button. When the user click the button, it will show the FormB which contain the CrystalReportViewer. I would like to to display the name which the user enter in the textbox on FormA on the CyrstalReportViewer.

The question is, how do I pass the textbox value to the Crystal Report Viewer The secondary question is how I am going to display the value on the Crystal Report Viewer.For you information, I am using VB.net.

View 1 Replies

Draw Line On PictureBox In .NET When Pass PictureBox As Parameter To Some Function

Jul 17, 2010

In VB6 I used some pattern of programming..I passed the picturebox as parameter to some procedure in some class and inside this procedure paint all needed graphics using this class methods.Now I want upgrade my application to vb.netBut all samples for line drawing show me how to draw inside paint event.[code]

View 2 Replies

Pass An Optional Parameter To A Function Of Type System.Drawing.Color - Error "Constant Expression Is Required"

Mar 22, 2012

I want to pass an optional parameter to a function of type System.Drawing.Color. The problem I am having is that when I declare the function it says "Constant expression is required" but I have tried variations of the following, including integers, full qualified indentifiers, even old vbWhite constants to no avail.

[Code]...

View 14 Replies

VS 2008 Template Function That Can Receive Different Parameter And A Type Parameter

Mar 9, 2011

I want to have a "template" function that can receive different parameter and a type parameter, like:[code]But Vb told me that tupeList is not defined... is there a way I can do that?

View 2 Replies

How To Pass A Function To A Function Is Functors/function Objects Avaiable In VB2010

Oct 12, 2011

I want to make an numerical integration method with takes in an analytic function and integrate it over a specific interval. For the numerical integration procedure I want to use some procedures in nr.com. The problem is that these are programmed in C++ and they uses functors to pass a function to the integration method. How can I do this in VB 2010?

I want to initialize the function (i.e. set a=1,b=0 for function y(x)=a*x+b) and then pass the function to the integration method. Then when the integration method call the function it only calls the function with one parameter (i.e. x since a,b is already set)

What is the best way to do this in VB2010?I want to make a general integration method where I can pass any single valued function and integration limits.

I have just started using VB, and from what I have found so far it seems like the tools you have is

- to us a delegate for the function
- to use a lambda expression for the function
- send a pointer/adressOf
- to create a function class/structure and submit this to the function

As for now I am most inclined to create a function-class. But I am not really sure how.F.ex. I make different classes for each "uniqe function" I want to integrate, but how can I pass them to the integration function when I need to specify the argument type in the integration-function-call?This seems like a basic problem which applies to many Math operations, so I think it would be very useful to clarify this.

View 2 Replies

Ado.net - Execute A Stored Function In Oracle Or Sql - Adding The Parameter Values Of The Function

Dec 13, 2011

I need to execute a stored function in oracle or sql through vb.net. I created a command object. Depending on the database type(oracle or SQL) i am preparing the Command text as Select functionName(?,?,?,?,?,?,?,?) from dual; (For Oracle) Adding the parameter values of the function. Now performing the ExecuteScalar which is not working saying invalid parameter. This works with ODBC connection string. But ODBC doesn't with 64bit. My Requirement: Code should execute a user defined stored procedure by taking the values at runtime.

View 1 Replies

How To Pass Parameter To EXE File

Oct 7, 2010

I am currently still learning to use VB.Net feature. Currently I am trying to execute a .exe file where there will be passing parameters to run the script. E.g. this how it works on the command prompt line:
C:Documents and Settingsproject1>textfile.exe file1.txt file2.txt file3.txt file4.txt
Above line will be able to run the textfile.exe script.

I am using VB .Net to create a User Interface where user will be able to use the 'OPEN CLICK' button to choose the files (which will display on a textbox) and click on a 'START' button to run the program. I managed to find a code - process.start() feature, however it cant seem to work..

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim MyProg As String
Dim executable As String
executable = "C:Documents and Settingsproject1 extfile.exe"
MyProg = TextBox1.Text
Process.Start(x, MyProg)

View 4 Replies

Object Must Pass Itself As A Parameter?

Sep 10, 2011

I have various shape objects, and I want each unique shape to implement a saveToDB method that simply calls a DB object that implements a Save method with an object as its input paramter. This DB.Save method will be a long case function that implements the proper SQL commands based on the type of attributes possessed by the input parameter object.how do I implement the SaveToDB method in my Shape class? Is it something like this:

Function Shape.SaveToDB
DB.Save(Me)
End Function

The goal here is to let each shape save itself without it knowing anything about database operations; I want to isolate db-specific information in my intermediary DB object, so the DB object will have to figure out what type of object wants to be saved into the SQL database and then execute whatever SQL instructions are needed. And then if I override the SaveToDB method in each shape subclass, I can avoid the case statement entirely, replacing it with a series of unique methods such as db.SaveCircle (ob), db.SaveSquare (ob), etc., sincle the caller already knows what it is.

View 4 Replies

Pass A DataRow As A Parameter To A Sub?

Apr 22, 2010

Is it possible to pass a DataRow as a parameter to a sub?The following example will (hopefully) make clear what I want to do.

Code:
myDataAdapter.Fill(myDataSet)
For Each myDataRow In myDataSet.Tables.Item(0).Rows
MySub(myDataRow)
Next

And the sub:

Code:
Private Sub MySub(ByVal drData As DataRow)
End Sub

I get an error at design time: Error 2 Expression does not produce a value.

View 3 Replies

Pass A Field As A Parameter

Jan 27, 2010

I have the following function:[code]I need to know if it's possible for a function to take a parameter as a type of field?

View 3 Replies

Pass A Parameter To A Query?

Feb 26, 2009

I am trying to load a combo box based on a selection of data from another combo box. I am not sure how I would pass the value to the object. My thought is I am loading all the table data onto my object and then I would run the query on the object. However I am at loss as to how I would go about doing that.

Private Sub cboOrder_SelectedIndexChanged(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles cboOrder.SelectedIndexChanged
Dim selecteditem As String

[Code]....

View 4 Replies

Pass An ID Parameter Using A Button?

Feb 10, 2009

how to use a button to pass a SQL parameter "ContactID" to the next page to allow the SQL to execute the Select Query. From what I've found here is what the code behind for the button looks like.

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ContactID As String
ContactID = Request.QueryString("id")

[code]....

Here is the error I'm getting back. What have I done wrong?Compiler Error Message: BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

View 2 Replies

Pass Event As A Parameter?

Nov 9, 2010

The reason why I need to do this is because I have a sequence of two lines of code that is littered all over my program, where I dynamically remove the handler to an event, then set the handler again. I'm doing this for several different events and event handlers, so I've decided to write a function that does this. [code]...

View 3 Replies

Sql - Pass Parameter As Date In .net Web?

Apr 18, 2010

I have a mail webform where I have to show the user only (-1) one day behind messages, so how do pass (yesterday)date as parameter and retrieve the only records of one day back ?This query is for 'ALL' messages, but I need to filter (yesterday) one day back messages and add a hyperlink or add in a dropdown ?

select MSG_SRNO,MSG_SUBJECT,MSG_ID,MSG_CHKD,
DOF_SENT,DOF_SEEN from MESSAGES_MAILBOX where USER=1234

View 2 Replies

Asp.net - Pass Two Parameter To Event Handler

Jun 13, 2011

i struggling to pass two parameter to an event handler basically when the page is load it dynamically create some control lable, textfield, and linkbutton when i click on the link button it fire an event handler, here is my problem i want to pass first the Product ID and quantity, the product id is fetch from the database passit thorugh an object where as the quantity it enter by the user first part of the code it connect to database loop through and display all record on the page dynamcally

[Code]....

View 2 Replies

Asp.net - Pass URL Parameter To Repopulate Page?

Apr 11, 2012

I currently have a page that is populated using a filter, which passes the parameters of the filter via URL.

I'd like to catch those parameters and give the user the opportunity to return to the page with the same filter applied to their view. Essentially, it's a back button. AKA: pass the parameters back into the URL so it repopulates the page.

View 1 Replies

How To Pass Integer As Unsigned Parameter In .Net

Jul 16, 2010

I'm new to VB.Net. I'm using a library call setInstance(ByVal instance As UInteger) in my VB.Net code. The parameter I need to pass is an Integer. Is there anything I need to do to convert the integer parameter to an unsigned integer? The number is garunteed to be positive and less than 10.

View 3 Replies







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