Accept A Variable Number Of Parameters?

May 26, 2009

I am trying to design a Function/Sub that will need to accept a variable number of parameters. Catch is that the parameters being passed are arrays themselves. As i understand it when you pass a variable number of arguments to a method, you pass them via an array. What im looking for is to make a method that would accept this form:

[Code]...

View 6 Replies


ADVERTISEMENT

Setting A Variable To Accept The Result Of A Function By Calling The Function With Many Parameters

Feb 17, 2011

I'm currently working with a client's VB.Net code, which was developed for them by a small development shop a few years ago and which they purchased and have been maintaining and uprgrading since. This client's primary developer is out on indefinite (likely permanent) medical leave and I'm now filling in until they bring in a full timer (as I'm a contractor here). My current task is to add some functionality to a the VB.Net code they purchased. I'm finding practices and techniques in the code that absolutely baffle me and can't make the code do what I want. I'm starting to wonder if it's me and was hoping to get some thoughts on the code I've encountered.

For example: Setting a variable to accept the result of a function by calling the function with many parameters, clearing the parameters in the function, setting them to some value, calling another function with those new values, then never using the values returned by the functions. I'll add a code snippet in the first comment since this is already getting long.

View 9 Replies

Use IN Operator With Variable Number Of Parameters?

Mar 11, 2012

I have a dataset connection to an MS Access database. I want to use IN operator in WHERE clause like: WHERE DepartmentID IN (1,2,3)This means that all record with an ID of 1, 2 and 3 will be filtered. But the problem is I cannot create a parameter like:

[Code]...

View 1 Replies

Variable Number Of Parameters In Query?

Jun 11, 2012

I want to query items from countries that are selected from a treeview (with checkboxes). However the number of countries that is selected by the user is not known beforehand. So how can I make a proper query when the number of OR operators is unknown? For example: SELECT DISTINCT Item FROM Countries WHERE Country LIKE @c1 OR @c2 OR @c3 etc� and then add the parameter values based on the selected countries in the treeview. I looked into parameter arrays but can�t make sense out of it really

View 13 Replies

[02/03] How To Accept Parameters

Oct 11, 2007

i have a Function in my Component(DAL), the Function Accept an input from textbox and return a dataset.

Public Function Search_lis(ByVal lis_key As Integer) As Dssearchlis
dasearchlis.SelectCommand.Parameters.Add(lis_key)
dasearchlis.Fill(Dssearchlis)

[code]....

View 9 Replies

VS 2008 Variable To Accept Textbox Value?

Mar 2, 2010

Error1Value of type 'String' cannot be converted to 'System.Windows.Forms.TextBox'With this code. Variables are in Module1.vb and this code resides in form1.vb

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
MyFile = Me.txFileName.Text

[code].....

View 4 Replies

DLL Declaration Won't Accept Constant String Variable?

Apr 26, 2010

I'm making a call to my DLL file (prototyping 30+ functions), and want to be able to switch between different versions of the DLL quickly while in development. Thus, i want to replace the literal string constant that follows the "Lib" key word, with a variable string constant. In case there's any confusion in my use of the jargon. I am currently able to do this:

[Code]...

View 1 Replies

Optional 'Color' Variable Parameters In Classes?

May 27, 2010

Is it possible to make Color variable parameters in custom classes Optional?Everytime I try, it gives me a "Constant expression required" error.[code]

View 2 Replies

Declare With An Arbitrary Number Of Parameters?

Jan 19, 2009

Is it possible to have a class, sub or function declared with an arbitrary number of parameters? And those parameters be a type, like generics? For example

vb.net
Public Class Test (Of T1, (Of T2))'The (Of T2) means that after the first parameter can be an arbitrary number of parameters

[Code]....

View 9 Replies

Create A Method With Unknown Number Of Parameters?

Jun 5, 2012

Is there a way to create a method with unknown number of parameters? And if it this the case: How is it possible to get access to them within this method? Do they have to be from the same type?

View 1 Replies

What Are The Conventions For Variable Naming In .NET To Avoid Confusion Between Parameters And Properties

Oct 21, 2010

In the example below, what would you name the parameter given that it is used to initialize the property FromDate?For class constructor methods, I like to have the name of the constructor parameter variable match the name of the property which is being initialized. For example, the parameter "fromDate" is used to initialize the module level variable "_FromDate" with the statement _FromDate = fromDate. Likewise, I could have alternatively written Me.FromDate = fromDate.

Proponents of C#'s case sensitivity would probably say that using a leading lower cased letter for the param variable name, which I believe is MS convention, is an acceptable approach to distinguish it from the Property of the same name but different casing.

However, VB is not case sensitive, which I generally appreciate. In the following example, I am using a param name that matches the property name, 'fromDate," and VB refers to the local instance when there is ambiguity. However, many would probably argue that this "ambiguity" introduces the opportunity for the developer to get confused and not realize which variable is being used. For example, my intent below was to have TWO params passed in, "fromDate" and "toDate" but I accidentily ommited one and as a result, the VB.NET did not warn me of the mistake because it assumed that the statement _ToDate = ToDate was equivalent to _ToDate = Me.ToDate instead of informing me that the variable on the right side of the assignment statement was undeclared.

Public Class Period
Property FromDate As Date
Property ToDate As Date

[code]....

In my judgement, we should have a convention for prefixing all parameter variable with a prefix, but hasn't the use of prefixes been discouraged by Microsoft? For example:

Public Sub New(ByVal paramFromDate As Date, paramToDate As Date)

..or maybe it could be shortened to pFromDate, pToDate...

View 3 Replies

Expand The Number 2 Like A Variable From 2 To 4.5?

Mar 6, 2010

i have this variable Dim odddivider2 As Integer = CInt(20 6) and i want to expand the number 2 like a variable from 2 to 4.5 how i have to make that

View 14 Replies

Can Combine V & And Number To Manipulate Variable

Jun 9, 2011

I have 10 variables that have numbers at the end in sequential order (e.g. V1, V2, V3, ect.). I would like to perform a function to find what the position is in an array and then add then add the value to the correct variable. Can I combine V & and the number to manipulate the variable?

View 2 Replies

Console Random Number To Variable?

Nov 8, 2009

I am making a simple console game. If you have ever heard of the board game code breaker you will understand better.

In my version of the game you will have to figure out a four number combination. The only numbers it can be is 1, 2, 3, or 4.

I need to generate four random numbers and put each on into its own variable. This allows me to call back each number.

How do I do this? I have been doing some research on random numbers and I use this code to generate four random numbers

Dim rnd As New Random()
Console.WriteLine("20 random integers from -100 to 100:")
For ctr As Integer = 1 To 20
Console.Write("{0,6}", rnd.Next(-100, 101))
If ctr Mod 5 = 0 Then Console.WriteLine()
Next
Console.WriteLine()

But I can't figure out to put each number into a variable so I can call the same numbers back.

View 9 Replies

Double A Number For Every Time A Variable Is Used?

Sep 18, 2011

If i have a variable '12'

and a variable 'hello'

how can i double the '12' each time the variable is used?

What im trying to do is have a textbox which the user writes in a number, the number they enter then determines the amount of times a variable is written in a textbox.

so if the user were to put '3' into the textbox and click go, it would print hello12hello12hello12, how can i increase the number 12?

what i want it to do is look like this when the user presses go: hello12hello24hello36

View 1 Replies

Get A Variable's Value Set To The Number Of Data Fields?

Oct 16, 2011

How can I get a Variable's value set to the number of Data Fields in my DataBase that is NOT Nul.

I have in a table 10 fields or columns Named: Ing1, Ing2, Ing3, Ing4, Ing5, Ing6, Ing7, Ing8, Ing9 and Ing10. This fields will all most never all be fild, will be fild from 1 upwords. I need to know how many of them is NOT Nul.

View 5 Replies

Holding Loop Number In A Variable

Jan 12, 2010

I have a button that searches through a binary file to bring up customer information with the following code:

[Code]...

My problem is, I need to create a variable which holds the record number, so that the record can be edited, and put back into the file at its previous location, how would I implement this? Not sure about the code.

View 3 Replies

How To Handle Variable Number Of Textboxes In Asp.net

Jul 19, 2010

I'm developing an app that should allow the client to add several content sections to a page (in tabs). However I haven't found a way to easily create a form for editing the tabs.Assume for now that a tab just contains a title. I have a form that adds a tab, that's simple. But I also want a form that displays a text input for each tab and allows the titles to be edited and saved. I'm struggling with two main concepts:How to dynamically display the fields after grabbing the tab data from the database (each tab has its own row in the table).How to loop through the submitted data and update each tab in the database.How to select a particular text field from the number (e.g. given "1", how to select the element with ID "TabTitle_ 1".[code]I thought something like TabTitle[0] would be acceptable and allow for easy looping (as it does in PHP) but it's "not a valid identifier" apparently.It's very possible I have the approach completely on its head.

View 1 Replies

Random Number Changing Variable?

Apr 14, 2009

have code to generate a new random number as follows (which is 100% working and generating numbers between 0-9:

Dim randomNumber As Integer
Dim randomNumber1 As New Random

[code].....

View 3 Replies

Saving A Random Number To A Variable?

Mar 14, 2012

as the title suggests i am trying to save a randomly generated number to a variable.I have done:

Dim randomposition As Integer
randomposition = Rnd(1, 1000)
when i do this it gives me this error:

[code].....

View 8 Replies

Use The Number In One Variable To Access A Set Of Different Variables?

Aug 10, 2009

I have a variable called VarNUM which stores a number from 1 to 10. What i want to do with this is based on the current number stored in that variable call a different set of variables from a module with Public Structure ITEM1. It has the same set of variables for ITEM1 - ITEM10 but with different values. So ya in raps how can i use the number in one variable to access a set of different variables? Something like ITEM(VarNUM) then the set of variables that all have same name but with different values so that i dont have to go,

Code:
if VarNUM = "1" then
name = ITEM1.name
store = ITEM1.store

[code]....

View 10 Replies

Variable 'Random Number' Is Used Before It Has Been Assigned A Value?

Aug 25, 2009

Variable 'RandomNumber' is used before it has been assigned a value. A new reference exception could result at runtime.

Sub RandomizeConLandLaunch(ByRef con As Integer)
Dim RandomNumber(,) As Integer
ConLandLaunch(con) = RandomNumber(1, 30000)
End Sub

what should i do ?

View 8 Replies

VS 2005 Illegal Variable Name / Number?

Sep 25, 2009

I know this isn't a vb.net question per se, but I hoping that somebody else out there can shed some light on my problem. I have a query that looks like this:

" select count(*) from OBJECT_DESCRIPTION " & _
" where INSTALLATION_ID = @1 " & _
" and SHAPEFILE_ID = @2 " & _
" and SDS_REC_ID = @3 "

I assign the above query to the commandtext of an OracleCommand object. I'm getting the infamous oracle 'illegal variable name/number' error when trying to execute the following code using the above:

[Code]...

View 7 Replies

Accept Only File Word And Pdf File And Other To Accept Only Images

Jun 2, 2011

One to accept only file word and pdf file and the other to accept only images(.jg|.bmp|.png|.gif)

View 1 Replies

Any Arithmetic Variable That Can Hold A Number Long

Mar 3, 2012

i am reviewing variabes, and just wondering any variables that can be used in math to hold a value this big =)

[Code]...

View 4 Replies

Assign A Number To A Single Variable It Does Not Equal The Same Value?

Nov 2, 2010

I have been searching the internet trying to understand in its simplist form why this behavior happens.

Dim mysingle As Single = 456.11 Dim mybool As Boolean = mysingle = 456.11

In the lines above mybool becomes false. I found this behavior when putting the single into a double I found extra digits showing. The .net documentations states a single is an approimate value I gatehr a single is a 32bit floating point number? But why are extra digits appearing when I have explicitly said what the number is.. surely the memory should store that numbers either side of my number are 0 to fill up the memory location?

View 3 Replies

Converting A Number Larger Than 255 Into A Byte Variable

May 17, 2011

I understand the concept of bytes and declaring variables to save on processing space. I understand that the max value that can be stored in a byte is 255. I cannot seem to wrap my head around my current issue. I don't have much experience working with byte manipulation.

[Code]...

View 3 Replies

Generate Any Random Number Between Range Using Variable?

Aug 17, 2011

I know that there is a way in which you can generate any random number between any range using the random variable. But my question is that is there any way to do the same thing but with letters?

View 1 Replies

Number Of Bytes To Be Variable And Always Have Spaces Between Eachother

Aug 19, 2009

I have hex strings that I would like to write a regular expression for. Here are some example strings.

[Code]...

View 3 Replies

Number Of Decimal Places In A Decial Variable?

Jan 16, 2009

I have got a decimal variable however i only want it to be to two decimal places. How can i set this?

View 4 Replies







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