Can Array String Values Be Assigned to a Struct

VB.NET

    Next

  • 1. How to rename form field on UploadFile()?
    Using System.Net.WebClient.UploadFile(), it assign the form field for the file name as "file". How do I change this? Thanks, Brett
  • 2. Use Excel files
    Hi, I'm new to VB.NET and i have a little trouble with a small task regarding use of Excel files. My VB application should be able to open an Excel file, extract some data, create another Excel file, create inside this new Excel file some table and write extracted data there. Nothing special... However, i'm not able to use Excel library in my application. I open Project -> Add reference -> Com -> Microsoft Excel 11.0 ... (version 2003). but when i use a simple example delivered with MSDN Library, it doesn't work. Does somebody have a working example just for me, to know if i include well the library and to see the first steps of using this library command ? thanks a lot, Maileen
  • 3. Opening files for output
    I typically open a file for writing like this: Public stLog As Stream Public swLog As StreamWriter ....... stLog = File.Open("c:\temp\Errors.log", FileMode.Append) swLog = New StreamWriter(stLog) But, what if I didn't know until runtime how many output files I needed to open? For example, what if there was a listbox with a list of filenames that need to be opened for output. How would I create and set the variables to initialized stream and streamwriter classes? Thanks for any help! Mark
  • 4. Variable values not showing = nothing
    This is probably something small but when i am debugging my vb.net class library code im not able to see the values of any of the variables when i hover my mouse over them. instead the value = nothing the only way that i can view the value of a variable is to write it to the event viewer using System.Diagnostics.EventLog.WriteEntry("value", strval) and then view this. This gets round the problem but is very slow and awkward + this behaviour should not be happening. Any help appreciated as it is quite difficult to debug at the minute. Thanks Colin Graham
  • 5. clipboard
    Anyone have any ideas how to copy a filename to the clipboard? I am building a reporting application and want to do the following: 1. Select blocks of text from rtf document #1 and copy this text to the clipboard (easy to do). 2. Paste the text into a blank document #2 (easy to do). This is where I'm stuck: 3. Automatically place the filename, page number and/or line number of the source block of text just above where I pasted the text into the blank document. Any gurus out there with some creative ideas? thanks. Gull.

Can Array String Values Be Assigned to a Struct

Postby Sam Clark » Wed, 21 Apr 2004 07:01:08 GMT

The following code puts a structure location in an array field: 
XrefArray(i) = "ArrayIn(i).Field" & RefText.Substring(NumStart + 1) 
-------------------------------------------------------- 
Array(i).Field1 is the value now assigned to XrefArray(i) 
-------------------------------------------------------- 
How can I now assign the value in this array and,
therefore, the value in ArrayIn(i).Field1 to another struct? 

OutputArray(i).Field1 = XrefArray(i) 

Or can I? 
Thanks for any help.

Re: Can Array String Values Be Assigned to a Struct

Postby Armin Zingler » Wed, 21 Apr 2004 18:25:07 GMT

"Sam Clark" < XXXX@XXXXX.COM > schrieb

See your first thread about the same question.


-- 
Armin

How to quote and why:
 http://www.**--****.com/ 
 http://www.**--****.com/ 


Similar Threads:

1.Difficult Question: Assigning string default values to class/struct ConfigurationProperty attributes

Hello Group,

I posted this in microsoft.public.dotnet.general about a week ago but
haven't had any replies....

The Visual Studio 2005 help for
ConfigurationPropertyAttribute.DefaultValue
provides the following sample:

/////////////////////////////////////////////////
[ConfigurationProperty("maxIdleTime",
    DefaultValue = "0:10:0",
    IsRequired = false)]
[TimeSpanValidator(MinValueString = "0:0:30",
    MaxValueString = "5:00:0",
    ExcludeRange = false)]
public TimeSpan MaxIdleTime
{
    get
    {
        return (TimeSpan)this["maxIdleTime"];
    }
    set
    {
        this["maxIdleTime"] = value;
    }
}

/////////////////////////////////////////////////

What I am wondering is how does the DefaultValue parameter from the
sample code work, i.e.:

>>   DefaultValue = "0:10:0",

TimeSpan does not have a constructor or "=" operator that takes a
string parameter, and TimeSpan does not implement IConvertible.  For
example, the following does not complile:

>>   TimeSpan ts = "0:10:0";

TimeSpan does have a Parse() method that takes a string parameter,
i.e.

>> public static TimeSpan Parse(string s);

but I do not see how it is associated in the above sample code.

So again how does this code from the sample work in regards to
assigning a string
DefaultValue to a TimeSpan value? i.e.:

>>   DefaultValue = "0:10:0",

My guess is TimeSpan.Parse() is somehow being called, but where?

TIA,
Keller Beyer
 XXXX@XXXXX.COM 

2.Mashaling a VB6 Array Of Struct to C# Array of Struct

Hello, 

Is it possible to convert a VB6 Array of Struct
to
a C# Array Of Struct ?

The test context is a C# application calling a VB6 ActiveX DLL Function 
using UDT (User Defined Type) and array of UDT.


***************************************
Example : (VB6AX is an ActiveX VB6 DLL)
***************************************

(VB6 Side)

Type VB6Struct
	d1 as double
	d2 as double
	l1 as long
End Type


(C# Side)

struct CSharpStruct
{
	double d1;
	double d2;
	double d3;
	long l1;
}
private VB6AX.CTest  AXInstance;	// ActiveX Class Instance

AXInstance = new VB6AX.CTest(); // Instanciate vb6 class

AXInstance.VB6Struct myData = new AXInstance.VB6Struct();
AXInstance.FillStruct(ref myData); 
// (FillStruct is a vb6 class method to fill the structure)

IT WORKS, BUT...IF I DO
CSharpStruct myData = new CSharpStruct();
AXInstance.FillStruct(ref myData);

I have a 
'cannot convert from ref CSharpStruct to ref AXInstance.VB6Struct'.

How to convert the ActiveX DLL Struct to the C# managed struct ?
The end of the story is that I would like my VB6 ActiveX DLL to fill an 
array of structure, called by the C# client.
The filled array of structure should be a 'managed' array of struct so I 
do have fast access speed to its elements later on in the application.

-> How to convert/mashal a VB6 Array Of Struct to a C# Array of Struct
(the C# array should be definied as an array of managed struct and not 
through the ActiveX unmanaged structure declaration)

VB6AX.VB6Struct[] array1 = null;	// array of unmanaged VB6 Struct
CSharpStruct[] array2 = null;	// array of C# managed Struct
					// bot struct represents the same thg


-> How to convert a ref VB6AX.VB6Struct to a ref CSharpStruct ?

-> How to convert a ref VB6AX.VB6Struct[] to a ref CSharpStruct[] ?


Can you help ?


Thanks.

3.Array string value assigned to a structure

The following code puts a structure location in an array field: 
XrefArray(i) = "ArrayIn(i).Field" & RefText.Substring(NumStart + 1) 
-------------------------------------------------------- 
Array(i).Field1 is the value now assigned to XrefArray(i) 
-------------------------------------------------------- 
How can I now assign the value in this array and,
therefore, the value in ArrayIn(i).Field1 to another struct? 

OutputArray(i).Field1 = XrefArray(i) 

Or can I? 
Thanks for any help.

4.assign byte array to struct or class

Hi,

how can I assign a byte array (read from a device) to a C# class or struct?

Christian

5.array of struct containing array of struct

I have a c++ function which requires that I pass an array of
structures which contain further arrays of other structures.  I have
been unable to do this in c#.  Could anyone give me some pointers on
how I might be able to perform this task?  I have my structures as
follows, and i'm passing an array of MySchema (possibly over a dozen)
into the function to be filled.  Each MySchema contains a 16 element
array of MyDataFormat.  I've managed to perform quite a bit of interop
programming successfully, but this one is really stumping me.


[StructLayout(LayoutKind.Sequential)]
public struct MyVersion
{
	public uint Major;
	public uint Minor;
}

[StructLayout(LayoutKind.Sequential)]
public struct MyDataFormat
{
	public ushort formatOwner;
	public ushort formatID;
}

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
public struct MySchema
{
	[MarshalAs(UnmanagedType.ByValArray, SizeConst=16)]
	public byte[] moduleID;
	public uint deviceID;
	[MarshalAs(UnmanagedType.ByValArray, SizeConst=68)]
	public char[] Name;
	public MyVersion specVersion;
	public MyVersion productVersion;
	[MarshalAs(UnmanagedType.ByValArray, SizeConst=68)]
	public char[] vender;
	[MarshalAs(UnmanagedType.ByValArray, SizeConst=16)]
	public MyDataFormat[] supportedFormats;
	public uint numSupportedFormats;
	public uint factorsMask;
	public uint operations;
	public uint options;
	public uint payloadPolicy;
	public uint maxPayloadSize;
	public uint maxSize;
	public uint maxIdentify;
	[MarshalAs(UnmanagedType.ByValArray, SizeConst=68)]
	public char[] description;
	public char path;
}

6. Marshaling struct containing pointer to array of arrays of struct

7. problem assigning value to struct member in for each

8. How Can I assign value to Struct variables?



Return to VB.NET

 

Who is online

Users browsing this forum: No registered users and 42 guest