Pass An Array Literal To A Sub Routine?
Apr 2, 2009
Isn't there a way in VB to pass an array literal? Say the subroutine ask for an array of integers and you have just one. Can't you do something like
DoSomething({MyNum})
instead of
Dim MyNums as Integer() = {MyNum}
DoSomeThing(MyNums)
I'm thinking I'm just missing some adornment to the array literal inorder pass it.
View 4 Replies
ADVERTISEMENT
Feb 15, 2011
I have a GridView with Cell 0 containing the ID that I need to pass to a Public Sub.
I cannot figure out how to pick the value from Cell 0 in order to pass it to the Sub. I have tried experimenting (see the Dimmed EventID below) but have failed. Here is my code:
Protected Sub gvAppointmentsCalls_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvAppointmentsCalls.RowCommand
[Code]....
View 2 Replies
Dec 7, 2010
Is it considered bad practice (VB.NET or any language) to code a function with both ByVal and ByRef parameters as used in my getFile function below?
Function getFile(ByVal channel As Integer, _
ByRef Filename As String, _
ByRef Filesize As String) As Integer
End Function
Dim status As Integer
[Code]...
View 1 Replies
Aug 2, 2011
I just learn how to create an array literal in VB.NET. [code]...
View 1 Replies
Dec 31, 2009
I need to write a routine that enters real (scientific) numbers into an array of 20 spaces then adds all the numbers together and prints out the contents of the array plus the total value in a format such as: 1.0 + 2.0 + 3.0 + ...... + 20.0 = 210.0 in Visual Basic 2008.[code]...
View 16 Replies
Jan 24, 2012
I am using sockets to send message between computers. I send the messages alright. What I want is when the message "x0x" comes, the client must be closed within 5 minutes. Teh admin can cancel the request by sending message "-xx" as well. The routine that checks for incoming connections and accepts messages uses WHILE TRUE...END WHILE since it must always listen. Once I get a message, I need to fire a timer control or other that fires within 5 minutes. But the program cant leave the WHILE TRUE at all. If i exit it early, the timer fires and the program does get exit. How do I fire the timer or other routine while still the WHILE TRUE routine checks for incomin connections and messages?
View 5 Replies
Apr 17, 2011
is there any way to reference a particular code routine in VB.net external to the current loop/routine?Example:
If Var01 < 5
[Routine A]
Else
[Routine B]
End If
where Routine A and Routine B are code sequences at the end of the entire program -- such as outside of the current sub or class? The idea would be to reference an otherwise repetitive code.
View 4 Replies
Mar 3, 2009
I have a sub routine where I pull in information from a database. I want to use variables from this sub routine in another sub routine. I tried making everything public but it doesn't want to be friendly and share.
Dim strEmail as String
Public Sub readDB()
strEmail = "whatever@doohikcy.com"
[Code]....
The readDB would read the database and set the variables and do whatever it needs to do. Then when they submit the form it would e-mail the form to whatever the email address was.
View 2 Replies
Feb 24, 2009
I am writing an OPC Client in VB.NET (2008) and I am using an OPC wrapper from Graybox. I am having some problems with the data types. I have an Array of String that contains all of the OPC Items that I wish to read from the OPC Server. When I attempt to use the Array of String, Option Strict causes the following compile error message:Error 5 Option Strict On disallows narrowing from type 'System.Array' to type '1-dimensional array of String' in copying the value of 'ByRef' parameter 'ItemIDs' back to the matching argument. How do I pass the Item ID's (all strings) in an array?
View 1 Replies
Mar 6, 2010
Does the following work in VB 2008 for passing an array to a function:
Public Function functionname(ByVal array1() As Short, ByVal array2() as Short) As Short
Also, can ByRef be used in place of ByVal?
View 2 Replies
Feb 4, 2011
I have 2 arrays X(n) and Y(n) where n can vary programmatically, no set value. I want to pass these two arrays between two subroutines.
Sub sub1()
...
call sub2(X,Y,n)
end sub
sub sub2(x,y,n)
...
end sub
I want to know how to prepare the arrays for the "call sub2" and how to extract the arrays in "sub2".
View 5 Replies
Jan 13, 2011
i have collection of data in an array. i need to pass it to web service as an array. how can i do that?
View 2 Replies
Jun 22, 2010
I have a VC++ DLL, which returns the sum of two long double values, passed as one dimensional array?l the right syntax to pass array to this dll from vb.net
currently, my code snippet is as follows: DllClass.vb
Imports System
Imports System.Collections.Generic
[code].....
View 1 Replies
Nov 20, 2009
I want to pass the entire array to the next function[code]...
View 3 Replies
Nov 23, 2009
i got the output of my project and it is displayed in the RT BOX and saved locally.. the values are stored as arrays.. the RT Box will display three values time, conc and preconc.the time, conc and preconc values are stored as arrays. my problem is, i should pass this values to the next form FORM2.VB.. and display the values in a graphical format.how to pass these arrays from one form to other??
View 1 Replies
Nov 4, 2009
how can u pass your array to another form
like example
FORM2
public test(2) as string
test(0) = "test1"
[Code]....
how can i get the value from the array test(0) in form 2 to in my textbox in form 1?
View 3 Replies
Jun 12, 2009
i need to pass array value to a function , here are the details
function MyTest(byval a as integer, byval b() as string)
if b is nothing
msgbox("no array")
[Code]......
View 3 Replies
Mar 25, 2011
I'm writing a wrapper class to expose a subset of the functionality of a .NET FTP library edtftpne from Enterprise Distributed Technologies.
When you call the edtftp's GetFileInfos method you get an array of FTPFile objects returned. I'm able to iterate through these but I don't know how to pass them on as a new and different object array containing only Name and Size for each file. Here's the code I have. Sorry it's a little confusing because I have my own class named FTPFile and the .NET library I'm using also has a class named FTPFile. I'm using both of them here. I should probably change the name of my class just to avoid confusion:
Public Function GetFileList() As FTPFile() Implements IFTP.GetFileList
Dim ftpfiles() As EnterpriseDT.Net.Ftp.FTPFile
ftpfiles = fCon.GetFileInfos 'Fill object array
[Code]....
I'd just pass on the object array that I'm getting from the GetFileInfos method but COM clients won't have access to the class/object EnterpriseDT.Net.Ftp.FTPFile without me rewriting it, I'm assuming.
View 1 Replies
Apr 7, 2011
I have a .Net application (VB in particular, although I would this to be as language agnostic as possible) that uses a COM object (made in C++). I need to implement a event in COM that passes a char array from C++ to .Net. I guess I need to convert the array to a managed array; How can I do this?
View 2 Replies
Mar 3, 2012
Im having a very difficult time trying to pass an vba array ive built from ms- access vba to a .net function.I don't have a com problem I can reference the library just fine from vba but and i can call a simple function from vba. however my problem exist when i attempt to try to pass an array to the vb.net function. vb.net code
View 3 Replies
Oct 29, 2010
I have a multidimensional array (not jagged array) that saves data from rows and columns of an excel spreadsheet. After it completes recording the data from Excel, I need to pass the array to another function.I understand how to pass a jagged array, but not a true multidimensional array.
Can someone point me in the right direction? I've done some searching on this site, and others, but most of the info only includes single dimension arrays or jagged arrays.
View 1 Replies
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
Mar 1, 2012
Im having a very difficult time trying to pass an vba array ive built from access vba to a .net function. I dont have a com problem I can reference the library just fine from vba but and i can call a simple function from vba. however my problem exist when i attempt to try to pass an array to the vb.net function. vb.net code
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1
Public otag As String()
[code].....
View 1 Replies
Dec 14, 2009
have a sub routine that I will create a string array dynamically. The XML is also listed,but it could be any of the values listed below. It will be something like this:
Dim offensiveLine() As String = New String() {"center", "right wing", "left wing"}
Dim defensiveLine As String = "defense"
Dim playerInfo = <Player><Name>John</Name><Position val="right wing"/></Player>
[code].....
View 2 Replies
Jun 25, 2010
I have a simple VB.Net Form that acts as an interface to a control library with a public API.
One of the API calls takes an Array of UIntegers ByRef:
Public Function Get_Values(source_id As Byte, first_value_address As Byte, number_of_values As Byte, ByRef valuesOut As UInteger()) As Integer
After the call, valuesOut will hold a list of values number_of_values long from source_id starting at first_value_address.
There is a hardware driven limitation that the max number of values returned is 15 regardless of requested length. I need to get 28 values into an array from my VB.Net code.
Is it possible to send only part of an array variable to the function similar to this C code?
uint[28] values;
Get_Values(0, 0, 15, values);//get first part
Get_Values(0, 15, 13, &values[15]); //get second part of data
View 3 Replies
Nov 4, 2009
Further to:- [URL] I now need to pass an array thus:- HTML
[Code]....
Myarray can be redimentioned. Since I need to pass an OBJECT to the thread how do I get the thread to recognise the passed array?
View 5 Replies
Apr 19, 2009
I am currently learning VB.net but for a project I need to create and array and pass it using a property. The data to be passed will be a train's destination, the time its due and the expected time of the train. I was wondering if someone could simplly explain how to first produce an array and then show how to pass it to a custom control
View 1 Replies
Apr 26, 2010
is it possible to pass an array as a parameter to a table adapter at design time in wizard in vb.net.
View 4 Replies
Nov 11, 2010
I have several parameters consisting of separate System.Byte() arrays. What I need is the syntax for a function declaration where the parameter is an array of arrays - I do not want to delve into System.Collections, and it's my preference not to CType each array into an Object and then back into a Byte().
Problem I'm having here is that:
Public Function MyFunc(arrayparam() As System.Byte) As System.Byte()
accepts a single-dimensional Array of individual Bytes.
Then Public Function MyFunc(arrayparam() As System.Byte()) As System.Byte()
View 12 Replies
Sep 29, 2010
What I am trying to do is automate a telnet session. I have working code that uses Sendkeys but I dont see a way to pass my array variable of IpAddresses to sendkeys. Whats the best way to accomplish automating a telnet session and reading in an array of Ipaddresses. Have I overlooked something in what seems like it should be simple? Or will I have to use sockets?
View 3 Replies