I feel silly for posting such a simple question, but here goes.
What is the difference between these statements - Case 3 doesnt work ... why
not?:
CASE 1
Public Case1 As Byte()
CASE 2
dim Case2() As Byte
Case 3
dim Case3 as new Byte()
I am trying to get something like this to work:
case1.copy (case1,case3,0) 3 2996
Ok, I seem to be getting it to work by:
Dim Case2(case1.len gth) as byte()
case1.copy(case 1,case2,0)
seems kind of wacky, is there any better way?
"gregory_ma y" <None> wrote in message
news:Ol******** ********@TK2MSF TNGP10.phx.gbl. .. I feel silly for posting such a simple question, but here goes.
What is the difference between these statements - Case 3 doesnt work ...
why not?:
CASE 1
Public Case1 As Byte() CASE 2
dim Case2() As Byte Case 3
dim Case3 as new Byte()
I am trying to get something like this to work:
case1.copy (case1,case3,0)
Hi Gergory,
Thanks for posting in the community. CASE 1
Public Case1 As Byte()
declare an Case1 as an type Byte array
CASE 2
dim Case2() As Byte
Same as above, except you can define the boundlist in the parentheses in
this method. Case 3
dim Case3 as new Byte()
This line will become dim Case3 as new Byte
This will call the new instance of Byte type.
[ <attrlist> ] [{ Public | Protected | Friend | Protected Friend |
Private | Static }] [ Shared ] [ Shadows ] [ ReadOnly ]
Dim [ WithEvents ] name[ (boundlist) ] [ As [ New ] type ] [ = initexpr ]
For detailed information take a look at the link below.
Dim Statement http://msdn.microsoft.com/library/de...us/vblr7/html/
vastmdim.asp
Here is the code in VB.NET
Sub Main()
Dim Case1 As Byte()
Dim Case2() As Byte
Dim Case3 As Byte
Dim Case4 As New Byte
End Sub
The according IL language generated.
..method public static void Main() cil managed
{
.entrypoint
.custom instance void [mscorlib]System.STAThrea dAttribute::.ct or() = ( 01
00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init ([0] unsigned int8[] Case1,
[1] unsigned int8[] Case2,
[2] unsigned int8 Case3,
[3] unsigned int8 Case4)
IL_0000: nop
IL_0001: ldloca.s Case4
IL_0003: initobj [mscorlib]System.Byte
IL_0009: nop
IL_000a: ret
} // end of method Module1::Main
So Case1 and Case2 are of the same type. So do with the Case3 and Case4.
It seems that you wants to copy and byte array from one to another. If I
misunderstand your meaning, please feel free to post here.
Dim Case2(case1.len gth) as byte() case1.copy(cas e1,case2,0)
I think the method will be ok.
'Declare Case1
Dim Case1 As Byte() = New Byte() {12, 34}
'Allocate the memory for Case2
Dim Case2(Case1.Len gth) As Byte
'Use the Copy function of Array to copy the data from case1 to case2
Array.Copy(Case 1, Case2, Case1.Length)
'Change the data in Case1
Case1(0) = 100
'This will write out 12
Console.WriteLi ne(Case2(0))
If you still have any concern please post here.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Gregory,
It appears that Peter answer what the difference is:
I want to point out a (potential) "off by one" bug in your sample:
The code:
Dim Case1(10) As Byte Dim Case2(case1.len gth) As Byte case1.copy(case 1,case2,0)
Will cause Case1 to be an 11 element array, while Case2 will be a 12 element
array.
It needs to be:
Dim Case1(10) As Byte Dim Case2(case1.len gth - 1 ) as byte case1.copy(case 1,case2,0)
As VB.NET expects the upper bound when defining an array, not the length.
Your case2 array would be one more element then your case1 array, hence "off
by one".
Remember that arrays start with index 0 in VB.NET.
Also VB.NET 2003 (.NET 1.1) gives an error if you include the trailing () on
Byte.
Hope this helps
Jay
"gregory_ma y" <None> wrote in message
news:Ol******** **********@TK2M SFTNGP11.phx.gb l... Ok, I seem to be getting it to work by:
Dim Case2(case1.len gth) as byte() case1.copy(case 1,case2,0)
seems kind of wacky, is there any better way?
"gregory_ma y" <None> wrote in message news:Ol******** ********@TK2MSF TNGP10.phx.gbl. .. I feel silly for posting such a simple question, but here goes.
What is the difference between these statements - Case 3 doesnt work ... why not?:
CASE 1
Public Case1 As Byte() CASE 2
dim Case2() As Byte Case 3
dim Case3 as new Byte()
I am trying to get something like this to work:
case1.copy (case1,case3,0)
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: truckaxle |
last post by:
I am trying to pass a slice from a larger 2-dimensional array to a
function that will work on a smaller region of the array space. The
code below is a distillation of what I am trying to accomplish.
// - - - - - - - - begin code - - - - - - -
typedef int sm_t;
typedef int bg_t;
sm_t sm;
bg_t bg;
|
by: Geoff Cox |
last post by:
Hello,
Can I separately declare and initialize a string array? How and where
would I do it in the code below? It was created using Visual C++ 2005
Express Beta 2 ...
In C# I would have
private string myArray;
|
by: bienwell |
last post by:
Hi all,
Data displayed on the datalist control is bound by the column name of the
dataset like this :
<%# DataBinder.Eval(Container.DataItem, "title")%>
Could I use an element of the array (i.e. index=0) which has the name
"title" in place of it ? For example:
|
by: Alan Foxmore |
last post by:
Hi everyone,
I'm new to C# and I was hoping I could get some clarification on the
syntax for jagged and multidimensional arrays.
Here is my question:
The following syntax is correct for declaring a multi-dimensional
array:
|
by: Sam Kong |
last post by:
Hello!
My question would not be very practical but just out of curiosity.
In JavaScript, Array is a subclass of Object.
Well maybe not exactly... but sort of...
For normal objects, you can access members by writing either of the
two.
obj.memberName
| |
by: amygdala |
last post by:
Hi,
I'm trying to assign values to an array by evaluating expressions like so:
$myArray = (
'sessionMaxInactive' =60*5,
'persistentMaxTime' =60*60*24*30
);
This doesn't seem to work. I've tried surrounding them with the brackets and
|
by: JJA |
last post by:
I'm looking at some code I do not understand:
var icons = new Array();
icons = new GIcon();
icons.image = "somefilename.png";
I read this as an array of icons is being built.
An element of the array is an object itself but what is this syntax of
the consecutive double quotes inside the brackets ?
|
by: Peter Olcott |
last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a
I think that the operator() member function does not work correctly, does
anyone else know how to make a template for making two dimensional arrays from
std::vectors ??? I want to use normal Array Syntax.
|
by: latin & geek via DotNetMonster.com |
last post by:
dear all,
hi. i have a little sub routine which works fine in my dummy test program,
but when i insert it in my main program it throws errors.
this is the subroutine:
Public Sub TagListing()
'adds a tag category from the tag stack into the unique tag
collection
|
by: =?Utf-8?B?U2hhcm9u?= |
last post by:
Hi Gurus,
I need to transfer a jagged array of byte by reference to unmanaged
function, The unmanaged code should changed the values of the array, and when
the unmanaged function returns I need to show the array data to the end user.
Can I do that?
How?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |