Delphi To VB: Define Data Types?
Aug 11, 2011in Delphi I have:
type osVer = (
osVerUnknown,
osVerWin95,
[code]....
I need to translate to VB...
in Delphi I have:
type osVer = (
osVerUnknown,
osVerWin95,
[code]....
I need to translate to VB...
I define 3 arrays: ID(n), Hour(n), Showed(n). If Hour(i) = actual time, I get the data pointed by ID(i), if not Showed(i).
BUT... I can add new hours or modify some existent, but I need to have the Hour array sorted. If I sort this array, the ID and Showed will point to different data.
So I though some different solutions:
1 - To make a string array with all inside (a 7 characters ID, a 5 characters Hour and 1 char for showed (T or F)). It could work, but, how can I sort the middle part of the array (Hour)? So, this don't work.
2 - A 3 dimensions "multitype" matrix (1 dimension of type Integer, the second of type Date and the third of type Boolean). I have no idea about how this can be done.
3 - A 3 dimensions string matrix, some like the "all inside" array: ID converted to a fixed size string, hour converted to a 5 chars string (hh:mm) and Showed converted to T or F. And sort the second dimension.
4 - Sell my copy of Visual Studio and drive a taxi cab
i wonder if it's possible to define a variable/property of more than one type. Let's say i want a property TextWebControl that is a WebControl and also implements Web.UI.ITextControl(f.e. like a TextBox or Label). But i don't want to enforce that it is a TextBox or Label, but only one that inherits from WebControl and also implements ITextControl so that it also would work with controls added in future releases of .Net-Framework.
.Net-Framework 4.0
Edit: I have retagged the question and added VB.Net because it's my default language. Normally it's no problem for me to understand C# also, but i must admit that it's difficult to translate generic stuff to VB.Net without experiences and it's also better documentated in C# than in VB. So i would appreciate(and aceept) a working example of a VB.net generic type of ITextControl/WebControl.From Marc's answer i understand that i need a generic class. But how do i instantiate it in SomeClass? This won't compile:
Class SomeClass
Public Property info As InfoControl(Of WebControl, ITextControl)
End Class
Public Class InfoControl(Of T As {WebControl, ITextControl})
End Class
Is there any way to define a Generic in VB.NET which will accept only Singles or Doubles? I tried the following things, based on what I've found online, but none compile:
Dim target As Nullable(Of {Single, Double})
Dim target As Nullable(Of T As {Single, Double})
Dim target As Nullable(Of T {Single, Double})
Dim target As Nullable(Of Single, Double)
Dim target As Nullable(Of T As Single, Double)
I want to specify that target can either be a Single? or a Double? only.
NOTE: I am mixing VB and C# - snippets come from different librariesI have a VB class definition as follows:
Public Class Session(Of TConnectionBuilder As {DbConnectionStringBuilder, New}, _
TConnection As {DbConnection, New}, _
TDataReader As {DbDataReader})
[code].....
i have a simple code just have a look End Class
[Code]...
When i add num1 and num2 as above, compiler gave error that -- Operator + is not defined for types "type" and "type".How to define the meaning of '+' or any other operator in such situations?
I'm trying to recreated some Excel code and an struggling with defining data types for use in Arrays.
Excel Code
Type Bags
feed_Bags As Long
drop_Bags As Long
level3_Bags As Long
mcs_Bags As Long
[code]....
How can I re-created this in VBA
I'd like to create a user-defined data type in VB.NET but don't know how to do it.Take an example.......say there's a variable to control the action of a timer control. The possible actions would be "no action", "run timer", and "stop timer."I could do this with an integer (e.g. 0=no action, 1=run timer, 2=stop timer), but I'd rather create a data type so that the options are more explanatory than a simple integer. Like so....
Private Timer_Action as MyDataType
Timer_Action=MyDataType.RunTimer
[code].....
In VB.NET I would like to create a complicated data structure with multiple types of data stored in an array like format (see below). I am trying to create a data structure that would look something like this: [Name; xLoc; yLoc; zLoc; [Jagged Array]] Note: Name needs to be dimensioned as a string, xLoc and so forth as integers. The Jagged Array would look like this:
[Code]...
SQL Server has a Data Type of "Float". Visual Studio has a Data Type of "Decimal". In other words, if I have a variable in a VB.Net app that is defined as a "Decimal" ...can I move that value into a SQL Server Data Table column defined as a "Float"?
View 4 RepliesI have been trying for days now how to create a process to the user to easily create a connection to any installed data types they have installed. I have found an example right inside vb2008. I never use this because I code my own connections, but this would be real nice if I could include it or duplicate it.
View 1 RepliesI'm trying to call a C++ DLL from inside VB.NET and am having difficulty with the data types (I think), I understand VB.NET far more than I do C++...I think my main problem is differing data types and I don't understand enough C++?In C++ the DLL is called (I don't have the source for the DLL which would solve my problem, I only have a sample project written in C++) by this;
_InitSensor = (InitSensor)GetProcAddress(m_hInstLibrary, "InitSensor");
_FreeSensor = (FreeSensor)GetProcAddress(m_hInstLibrary, "FreeSensor");
_ReadTEMPsh10 = (ReadTEMPsh10)GetProcAddress(m_hInstLibrary, "ReadTEMPsh10");
_ReadType=(ReadType)GetProcAddress(m_hInstLibrary,"ReadType");
(Variables Declared Previously in other file like this;)
typedef char* (*InitSensor)(char ICType);
typedef void (*FreeSensor)();
typedef double* (*ReadTEMPsh10)(BYTE n);
typedef double (*ReadType)(BYTE address);
I use Philip's MfRc500.dll for communicating with RFID chips. It contains a function for reading data, which is defined like this:[code]The second parameter in function Mf500PiccRead can returns "16 byte data block", so my long data type is too small. If I use byte() instead of long, then i get ExecutionEngineException Exception.
View 3 RepliesI'm torn between using UniqueIdentifiers(UID) or some other field as my primary key for my new web app. I have two tables. I need to be able to find the UID on one record in Table1 and put that UID in a new record in Table2. I also need to be able to create a brand new UID for the new record in Table2 on the fly.
View 3 RepliesVisual Basic 2010 (Express). If I take a string from a textbox and assign it to an integer variable, I'm under the impression that you're supposed to use CInt to explicitly convert the contents to an integer.intMyCount = CInt(txtUserInput.Text)However, if I don't do that, it still seems to work. Similarly, if I have an integer and concatenate it into a label's text property, it still works: lblResults.Text = intMyCount & " number of times."
rather than using intMyCount.ToString.Why does it work? Is VB doing implicit conversions when possible? Are there examples where not explicitly converting with .ToString or using CInt would cause unexpected results?
I am trying to wrap a c++ dll and can use system.runtime.interopservices.dllimport and declare function to call functions from the dll. But how do i wrap the data types and everything else?
View 1 RepliesI am using Delphi 7 to try to use a .DLL created by VB.net. When I run TDUMP.EXE on the .DLL, it reports no exported data available. The VB.Net .DLL uses "RaiseEvent" to return data.[code]
View 1 RepliesI want to compare two objects whose type may be diffrent.
For eg, I expects 'true' for comparing 1000.0(Decimal) with 1000(Double) . Similary, it should return true if I compare 10(string) and 10(double) .
I tried to compare using Object.Equals() , but it did NOT work.It return false if two objects have different data types.
Dim oldVal As Object ' assgin some value
Dim newVal As Object 'assgin some value
If Not Object.Equals(oldVal,newVal) Then
[Code]....
I am create a mysql table with TIME data type Field. And then store time type data into that field. But can't view in datagridview ( not show in other controls, like LABEL,TEXT,LISTBOX etcc..) . Using method is:
(LEAVEFROM TIME DATA TYPE, LEAVETO TIME DATA TYPE)
Dim cmd As New MySqlCommand
Dim adapter As New MySqlDataAdapter
Dim table As New DataTable
[code]....
Run time display error:ArgumentException was unhandled Argument 'Prompt' cannot be converted to type 'String'
I have a table that has a "date" column and an "amount" column. I also have a form with two DateTimePickers ("dtp1" and "dtp2"), a button and a label. The label should show the total amount calculated from the rows whose "date" value is between the dates picked by the user with the DateTimePicker controls.
I keep getting an error with my SQL statement, and I don't know what to try. My code is as follows:
Private Sub getData(ByRef total As Double)
Dim connection As OleDbConnection
connection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\proyectogestion.mdb")
[Code]....
I tend to use
If Not IsDBNull(dr("data")) Then
myData = dr("data")
End If
to catch nulls. Is there a better way? It seems I use this over and over again? Anyone write a function to check this something like
mydata = IfNotNull("data")
I don't know how to handle the different data types that could be returned.
I never thought I'd say this, but I am getting pissed at how easy it is to just plop down a variable in python without any declaration. I have an existing python script which interfaces with a server, and it builds its own messages to be communicated via sockets. What I am trying to do is take the command line python script and convert it into a VB GUI app that is more user friendly.
[Code]...
I'm creating a VB.Net Windows Form Application. Apologies if this is not clear as I'm still new to .Net. This consists of a text box and a gridview.The user is able to write SQL code in the textbox, click run and see the results in the gridview.It uses a SQL DataAdapter and the fill method to a datatable to populate the gridview.My problem is that I need to know the SQL datatypes for each column in the data table (NOT the .net ones). I.E SQL Server 2008 data type 'Date' is stored as System.Datetime in the datatable. I need to know if the SQL Server datatype is 'Date' or 'Datetime'.
View 2 RepliesI have a class with a Property called 'Value' which is of type Object.Value can be of any type, a structure, a class, an array, IList etc.My problem is with the setter and determining whether the value has changed or not.This is simple enough for value types, but reference types and lists present a problem.For a class, would you assume that the Equals method has been implemented correctly, or just assume that the value has changed every time the setter is called?If I did assume it's changed, then perhaps I should assume it for value types as well, so that the behaviour is consistent.
View 2 Replies.NET converter (either C# or VB.NET)? I've inherited a bunch of Delphi code, never seen Pascal before and rather than learn it, I'd rather just try to use an automated converter, if available, and clean up the code after that. Can't seem to find this kind of tool anyway I search
View 3 RepliesI have a value of: "2.54334881002458E-37" and i keep getting "overflow" exception when i'm using a double.what should i use to make this work?
code snippet:
Dim curries, act, cat As Double
For Each dataRow As DataRow In dt.Rows
curries = dataRow("Activity")
getting the error when i try to assign Activity to curries.but "activity" is a string in the database....
How to create a class which inherits from a data type, specifically from Char data type? I just want to add one property to it. If it's not possible, are there any other ways to accomplish this?
View 2 RepliesI want to have data types name inside enum as given below
Enum FieldTypes
String = 0
Boolean = 1
Date = 2
End Enum
Is there any method to achieve this?
I would like to populate a Combo with all the type names that a DataColumn can be ("System.String", "System.Boolean", etc). How can I do that without having to manually add the combo items?
View 4 RepliesI have a question (suppose to be simple). The question related to reading text file which is in the below format.
[Code]....
What I want here is to store the first data column in the file to be stored in AreasString and 2nd column in Level, 3rd in Importance and so on untill the end of the data. In addition, How can I check the type of data? For example, if I want to say: If 10.25 is double then msgbox ("it is double") else msgbox ("it is integer")