Convert Vb6 Type To C# Struct?
May 31, 2012
I am converting an application originally written in vb6 to vb.net. One of the things this application does is that it sends a object to a dll. I tried converting the type to a structure and p/invoking the dll but it does not seem to work
'Define WICS Communications Control Block (CCB).
Type WicsCCBType ' Create user-defined type.
CCBNum As String * 1
[code].....
View 3 Replies
ADVERTISEMENT
Mar 24, 2010
I am looking into generics in .NET, and was wondering about the where T : struct constraint. I understand that this allows you to restrict the type used to be a value type. My question is, without any type constraint, you can do a limited number of operations on T. Do you gain the ability to use any additional operations when you specify where T : struct, or is the only value in restricting the types you can pass in?
I guess the question I am actually asking is that if I were to write, (in a discussion about how to use generics), "Now that you have constrained the type argument to value types, you can also do _________ on/with objects of that type", Is there anything to put in that blank? I can think of things for the other constraints, but not this one.
View 3 Replies
May 20, 2009
In the code base I'm working in there have a method that has the signature
Public Sub SetDropDownValue(Of T As Structure)(ByVal target As ListControl, ByVal value As Nullable(Of T))
The method I am writing is passed a parameter of type object.
How can I cast the object into something that can be passed into the SetDropDownValue method?
View 2 Replies
Apr 25, 2009
I have a text file with the following information:
-----------------------------------------------
Model: Accord
Manufacturer: Honda
Year: 2004
VIN: FJ235FJSLO323434DJS
[Code].....
how to setup my loop to insert the text data into my struct array.
View 3 Replies
Dec 8, 2009
I just converted the following code from c# to vb.net. It is functional and works correctly with my company's firmware/devices. My next challenge. Previous serialport code used much more readable structs which where then converted (after building a packet) into byte() automatically as part of the serialport encoding. (this is my understanding)How could I
1. morph byte arrays 'ToSocket' and 'ToMTP' below into structs and
2. convert into byte array for Socket.BeginSend(byte(),.....) to stream out to remote devices?
Imports System.ComponentModel
Imports System.Text
Imports System.Net.Sockets
[Code]....
View 3 Replies
Oct 22, 2009
I want to use explicit conversion (CType function in VB.NET) to convert the variable d from double type to integer type and store the result as 132.
Imports System.Console
Module Module1
Sub Main()
[CODE]...
This is my code. But Visual Basic tells me an error: Error1Type 'i' is not defined.C:\Users\mihaispr\Desktop\Conversie explicita\Conversie explicita\Module1.vb1922Conversie explicita
View 4 Replies
Aug 30, 2010
I've pieced together some information from other posts but I'm stuck. The first part works fine. Basically I query the database using LINQ and then I loop through the results generating a report.
[Code]...
View 2 Replies
Nov 19, 2010
i am getting all filenames from a directory.parsing out the directory names & the .vb extension then converting those filesnames to classes.Every file in the LPCriteria direcotry is its own class with a "Evaluate" function.[code]
View 1 Replies
Aug 28, 2009
In a VS 2008 ASP.net 3.5 aspx.vb file, Response.Write(DDL.SelectedItem) worked very well.But "Dim filenameDDL As String = DDL.SelectedItem.Text" did not. Then I tried the following codes and found the problem -- Conversion from type 'ListItem' to type 'String' is not valid.
[Code]...
View 1 Replies
Jun 12, 2010
. I get this error: "Cannot convert lambda expression to type 'string' because it is not a delegate type" - keyword select become underlined in blue
[Code]...
Above code should displays drop list of employees first name and last name in a combo box
View 2 Replies
Apr 6, 2011
Every time I do something that ends up using windows API calls in VB, I always end up having to look up the values for the windows constants. Does anyone have a file with a class or something for VB that defines all the WIN-API constants?
View 2 Replies
Mar 4, 2012
Trying to setup a VB array (jagged array?) that has an entry for each rcd that contains the # of bytes in the data, as well the data. If it's possible how do you setup and loop through something like this is VB?
EX (1024 max bytes of data but it could vary):
struct inpRcd {
int rcdSize;
byte data[MAX_RCD_BYTES];
} inpRcds[MAX_RCDS]
View 17 Replies
Jun 1, 2011
I have the following
Public Structure Foo
dim i as integer
End Structure
[code].....
View 2 Replies
Nov 8, 2011
I have a struct setup like the following[code]...
I then loop through a counter and add each PersonInfo object to the Dictionary. The Primary defaults to false if the Code is already in the Dictionary, but if it has not been inserted into the Dictionary, I want to set the Primary to True. It would be easy to check if the Code was the key, but I can't because the Code is not unique.
View 2 Replies
Jun 11, 2011
i being ordered to change my function skill to returning value by using struct but not using pointer. may i know what is the pro and con between this 2?
View 1 Replies
Apr 16, 2012
I have an application that reads data from a SQL query into a list corresponding to the rows of the query. So, I have something like this:[code]What I'd like to know is if I should be using a class (as above) or a structure, and what the difference may be in terms of memory or runtime, if any.
View 3 Replies
Sep 20, 2010
I have a DateTime struct I use, and sombody commented out the part where it was created (but not declared) When I was using it, myDate.DayOfWeek == DayOfWeek.Monday returned true.
If the part where it is created is commented out, how can it tell me it's monday, instead of throwing some exception?
View 2 Replies
Jan 15, 2009
How can I use a string parameter for a method and convert this to a type.
I am using reflection to retrieve items within an enumeration:
CODE:
Currently I am creatnig a separate method for each enumeration in order to retrieve it's values.
What I would like to do is pass the name of the enumeration as a parameter to the method and cast this as a type.
View 4 Replies
May 25, 2012
I am needing to write data to a usb device. The USB device uses a byte array (DataArray() as byte) to store the data. How can I assign a struct object (myStruct(0)) to the byte array. I run into the error "Value of type byte cannot be converted to 1-dimensional array of byte" when I try to cast the struct as a byte.
View 10 Replies
Oct 29, 2009
I have a Function that returns a struct in VB.NET:
CODE:
Where as in my struct I have two variables:
CODE:
When I try to populate the structure as shown above, I get an a nullvalue exception.
View 2 Replies
Feb 14, 2012
Public Structure testStruct
Dim blah as integer
Dim foo as string
[code].....
View 3 Replies
Dec 20, 2011
I am creating a simple console application in vb.net in order to convert a file from any type to utf8 but i can't figure out how this thing works with the encoding. I know that the source file is in Unicode, but when i convert it to a new format i get junk. Any suggestions? i am not sure if my code is correct
this is my code.
[Code]...
View 2 Replies
Jun 13, 2011
I'm trying to do this in an item_databound event of a datagrid in asp.net
Dim EntType As EmployeeEntity = DirectCast(e.Item.DataItem, EmployeeEntity )
but I encounter the error
Cannot convert to class EmployeeEntity
The EmployeeEntity class has the same members as the items in e.Item.DataItem's DataRowView items. so how else do i cast the contents, without having to actually set each property of EemployeeEnity individually, from the e.Item.DataItem ?
View 2 Replies
Dec 27, 2010
I ve the following stream but I don't know its encoding type because the stream reader detects encoding from byte order marks
Dim reader As StreamReader = New StreamReader(respStream, True)
so how can I detect the encoding type AND convert it to another type? (for ex. from ASCII to UTF8)
PS: What is the difference with the following line?
Dim reader As StreamReader = New StreamReader(respStream,
Encoding.ASCII, True)
View 1 Replies
May 22, 2012
i am getting id from the url and pass it to sqldatasource - selectcommand i get thefollowing error : Conversion failed when converting the varchar value '<%=MyIdVal%> to data type int.
code behind :
Public Partial Class Edit
Inherits System.Web.UI.Page
[code].....
View 1 Replies
Apr 26, 2010
I'm using vb.net 2008 edition and i was wondering if there a way to convert an array type to another array type. For instance say i dim an array as string and then want to convert the array to the integer data type for sorting, how would i go about this?
View 1 Replies
Jan 13, 2011
In VB.NET 2010, how to return a boolean value as generic type without compile warning?
View 2 Replies
Dec 21, 2009
convert binary image to jpg or png one.i've saved some types of images in my database but now i want to display them but i can't do it
View 1 Replies
Jul 26, 2009
wrote a procedure that accepts as input a parameter of type decimal, or type Long as well as an array type ar() as Boolean. First thing I will do in the procedure is establish just what type of parameter I received. No problem with the scalar types, I'll use the .GetType,determine whether it's Long of Decimal, and assign the parameter I just received to a variable of that type by using convert.toInt64 or convert.toDecimal, then do what I need to do. Not so if the parameter I received happens to be an array. .GetType will tell me what it is, for example returns "system.int64[]" if its an array of Longs, but then I fail to assign it to a variable for further processing as there appears to be no conversion method to do that.
View 2 Replies
Nov 18, 2010
[code].....
View 3 Replies