Possible To Use String As Array (Name Of Variable)
Feb 3, 2011
Is it possible to use a string as an array? I mean: I have several arrays
Dim a10() As Integer = {530}
Dim a15() As Integer = {370, 231}
Dim a20() As Integer = {305, 176, 126}
'I declare a variable as a string and I assign the name of an array to it
Dim tablaalfa As String = "a10"
'I retrieve data from the array using the name of the variable instead:
lbl1.Text = tablaalfa(2)
View 9 Replies
ADVERTISEMENT
May 23, 2011
I have a strange problem with the following code:
Code:
Private Sub Listener()
Dim infiniteCounter As Integer
[code]......
View 3 Replies
Jul 21, 2011
For example, I have string variable (MyString) as below.MyString = "First word || second order || third example || fourth item || fifth stuff"
There are separator "||" at MyString variable. I want MyString variable is spited based on separator "||"and stored it into new array variable.
Could you advise me the most efficient code to do this job in VB?
View 4 Replies
Nov 18, 2009
I'm looking for a way to search a string variable for two words and copy the text in between them into another variable. This needs to be done as many times as the match occurs.
View 3 Replies
Jun 2, 2011
Say I have something like this
Dim Level1 as Integer = 83
Dim Goal as String
Goal = InputBox(" What level is your goal?")
[code].....
View 7 Replies
Jan 30, 2011
what's the difference between variable array and object array?
View 7 Replies
Apr 4, 2009
I am trying to insert a string variable inside of two strings, and make a combined string. Public Sub Page_Load() Dim Id As String Id = Trim (Request.QueryString("Id")) End Sub Dim mp3text as string url... & Id & ".mp3" My goal is to make the mp3text variable have a string that is: url...(If Id is 7) It is for some reason not connecting up correctly. I checked what string it is outputting and this is what it is giving: url...It is missing the Id content.
View 12 Replies
Mar 11, 2010
my code is :
[Code]...
The error is Value of type '1-dimensional array of string' cannot be converted to 'String'.
View 2 Replies
Apr 14, 2010
I have this function:
Public Sub DoStuff(ByVal type as System.Type, ByVal value as Object)
End Sub
The 'value' argument is always an array of the same type as 'type'. How can I loop through the values of the array?
I'd like to be able to do something like this:
DoStuff(GetType(Integer), New Integer(){1,2,3})
Public Sub DoStuff(ByVal type as System.Type, ByVal value as Object)
//Strongly types arr as Integer()
[Code].....
View 3 Replies
Feb 9, 2011
The code below works for the class that I hard coded "XCCustomers" in my RetrieveIDandName method where I use CType. However, I would like to be able to pass in various classes and property names to get the integer and string LIST returned. For example, in my code below, I would like to also pass in "XCEmployees" to my RetrieveIDandName method. I feel so close... I was hoping someone knew how to use CType where I can pass in the class name as a string variable.
Note, all the other examples I have seen and tried fail because we are using Option Strict On which disallows late binding. That is why I need to use CType.I also studied the "Activator.CreateInstance" code examples to try to get the class reference instance by string name but I was unable to get CType to work with that.When I use obj.GetType.Name or obj.GetType.FullName in place of the "XCCustomers" in CType(obj, XCCustomers)(i)I get the error "Type 'obj.GetType.Name' is not defined" or "Type 'obj.GetType.FullName' is not defined"
'+++++++++++++++++++++++++++++++
Imports DataLaasXC.Business
Imports DataLaasXC.Utilities
[code]....
View 2 Replies
Dec 5, 2011
These is the content of my txt file which is saved in D drive in my pc abc,1,2,3..I tried the flowing but it didn't work:[code]I am getting error on this line.. data = line.Split(","c)...it says this line isn't in use anymore or something and that I rather use LineInput but thats asks for filenumber and i don't know what that is. I am sorry but I am a complete beginner. what else can I try? [code]ok that error is gone now but now if I want to add these values to a list box..how can i do that?
View 1 Replies
May 30, 2012
I have a List(of String()). I have written a custom comparer (implements IComparer(of string)) to do an alphanumeric sort.Is there a way to sort the List using a given index to determine which position in the String() to sort by? In other words one time I might sort by Index = 0 and another time by Index = 3. The length of all String() in the list is the same.For reference this question is similar to Sort List<String[]> except I am using VB.net and that question is hardwired to Index=0.
EDIT from OP's comments:I started simple with the non custom comparer but I am getting an error: expression does not produce a value. Not sure what I am doing wrong.Here is the code:
Public Shared Function SortListOfStringArray(ByVal ListOfStringArray As List(Of String()), ByVal SortByIndex As Integer) As List(Of String())
Return ListOfStringArray.Sort(Function(x, y) x(SortByIndex).CompareTo(y(SortByIndex)))
End Function
View 1 Replies
Jul 13, 2010
i have an array contains a-z.Then i have a textbox and when click on the button, it will replace the text inside the textbox to the index number of the array.Example, from "abc" will become "0 1 2" The code below do the job.how to do so that i can replace the text inside the textbox from "0 1 2" back to "abc" based on the array?
Dim txtKey As String = readKeyTxt.Text
readKeyTxt.Text = ""
For Each b As String In txtKey[code].....
View 2 Replies
Feb 14, 2012
if i generate a label dynamically i can change the text as followed, variable is a string: Form.Controls(variable).text = "test" I now have a sub that will create some and will get some information out of arrays. I have a lot of them. I only want the function for tat specific array. I do not want a case or if. Thats why i was wondering if i can use a variable in the array variable. [Code] But instead of TestArray being hard-coded i want it to be replaced with Shelf. So whatever gets send into the sub will change the array that i'm using. Is that possible some how or is the way totally wrong?
View 1 Replies
Oct 2, 2009
just found out that replace(string does not do the same as string.replace when my string variable was an empty str the first one returns "nothing" and the second returns an empty string (as expected).just sloppy coding anyhow, it was a function that was converted from classic asp and never rewritten properly. [code]
View 1 Replies
Aug 25, 2010
I need to append STRINg to Array and cast it 1-dimensionalArray
Dim remoteFileNames(0)
As
String
[Code]....
Here "FtpRemoteDirectory" is a string and ftpFileNames() is the Array String which list the FileNames.
and remoteFileNames is 1-dimension array
View 1 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
May 27, 2010
I'm having problems with marshaling in VB.NET to C++, here's the code :
In the C++ DLL :
struct APP_PARAM
{
[code].....
View 2 Replies
May 30, 2012
I'm writing reports in Report Designer (VS 2008), and I've reached a point where I have to circumvent the restrictions on using aggregates in groups. I believe this can be done by utilising custom code, which is written in Visual Basic as far as I know (not sure what version though).
I have a dynamic number of "Pools", which each contain "Models". Each Model row needs to set the Pool Multiplier to the maximum of the current multiplier and proposed multiplier. The Pool row (parent group row) then needs to get the Pool Multiplier.[code]...
View 1 Replies
Sep 6, 2009
Is it possible to set the name of a variable to the value of an array? so I have the array[code]...
View 3 Replies
Oct 7, 2009
I have an array defined As string and the value stored in site is like "7E", "A1" and so on. But in order to send out this array through serial port. I need to change the the array to As Byte instead of using As String. How can I convert it?
View 8 Replies
May 27, 2009
I've been working with a sig capture application sample on a windows mobile device, The data is sent via IP to a host as a byte array and is then drawn onto the screen of the host as it appeared on the client. I was able to get this into the form of a bitmap object so I could print it or save to a jpg file. That all works well. The problem now is that I need to store this data in a database and then be able to recall it at a later time and recreate the signature image.
The byte array data is much smaller than the actual image so I would like to store it in that form. My issue is that when I convert this byte array into a string and back again my program can no longer re-create the image. Once I saw the problem I created the code below as a test and added the msgboxes to get an idea what was happened to my data.
[Code]....
View 2 Replies
May 12, 2011
i have 2 string arrays and I want to merge them together then put the elements into a third string array ..
for an example :
string1="a","b","c"
string2="d","e","f"
after merging:
string3="a","b","c","d","e","f"
View 2 Replies
Aug 27, 2011
Im working on a program and I get this "Value of type '1-dimensional array of String' cannot be converted to 'String'." heres the code that gets this error:
[Code]...
View 3 Replies
Jan 17, 2010
I don't understand why the line final.join etc pops up with these errors!! Value of type 'String' cannot be converted to '1-dimensional array of String' And Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated This is my code.
[Code]...
View 6 Replies
Jul 29, 2011
I want the Function to accept List(Of String), Array & String and similarly return List(Of String), Array & String respectively. The Function simply adds a string (month) to the input collection. I just want to use it for string, array and list with needing to think of conversions.
[Code]...
View 2 Replies
Sep 18, 2011
how to add a counter variable to this array? My code always stops when it gets to an empty array. I can't figure out how to make a counter variable to make it stop.
Private Sub btnTwo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTwo.Click
For Each i In PlayerArray
[Code].....
View 7 Replies
May 16, 2011
simply i am trying to add some value in array variable for datafiled.
dddd
Dim dkeyn(docc.GetElementsByTagName("pkey").Count) As String ' it have 4
Dim ir As Integer = 0
[Code]....
View 7 Replies
Mar 16, 2009
I have a variable (double) which has a constantly (infinitely) changing value. I would like to store all the values of this ONE variable into an array. My variable and array are:
Dim x as Double
Private y as Double() = New Double (499) {}
I tried doing this:
[code].....
View 19 Replies
Mar 22, 2010
i want to declare an array with a name that is the value of a variable. I need to do this because i want to create arrays from a text file that i'm reading.Basically, if someone could make this work then i should be able to change it to fit my use.
Dim var1 As String = howdy
Dim var1() as Integer
In this case i'd like to be declaring an array with the name 'howdy' that stores integers. In reality i'm looping a bunch of read names and would like to create an array for each name i read- but i'm quite capable of sorting the rest.
View 6 Replies