Pointers To Variable - Vb Doesn't Support But C# Does
Jan 17, 2010
Since vb doesnt support pointers but c# does. I am using a wrapper dll that requires a pointer to some singles to be passed within the method. I get an error that the method has some parameter types that are not supported. How can i pass a pointer to this method if vb .net doesnt support pointers.
I have to upgrade a legacy VB6 app to VB.NET; this app uses a function call from a .dll that takes a memory address as one of it's parameters. The VB6 app does this with the VarPtr() function, but this function does not exist in .NET. How do I retrieve the memory location of a variable in .NET?
SELECT Convert(char,DATEDIFF(m, Temp.Opening_Date, '2011-05-01')) As MonthDifference From Temp
It was successfully retrieve the data from SQL Server. But when I bind it to my vb.net datatable, the value is null. It's seems like vb.net datatable doesn't support datatype from DateDiff... What can I do?
Note: this is not a duplicate of Jeff's question. That question asked "Is an equivalent?" I know there isn't, and I want to know why! The reason I ask is that I've only just become clear on how important it is, and the conclusion seems very strange to me. The Exception Handling block of Microsoft's Enterprise Library advises us to use this pattern:
[Code]...
The policy is defined in an XML file, so that means that if a customer has an issue, we can modify the policy to assist with tracking down (or perhaps papering over) the problem to give them a fast resolution until we deal with it properly - which may involve arguing with 3rd parties, about whose fault it all is. This is basically an acknowledgement of the simple fact that in real applications the number of exception types and their "recoverability" status is practically impossible to manage without a facility like this.
Meanwhile, the CLR team at MS says this is not an option, and it turns out those guys know what they're talking about! The problem is that right before the catch block runs, any finally blocks nested inside the try block will be executed. So those finally blocks may do any of the following: Harmlessly modify the program state (phew, lucky). Trash something important in the customer's data, because the program state is screwed up to an unknown degree. Disguise or destroy important evidence that we need to diagnose an issue - especially if we're talking about calls into native code. Throw another exception, adding to the general confusion and misery.
Note that the using statement and C++/CLI destructors are built on try/finally, so they're affected too. So clearly the catch/throw pattern for filtering exceptions is no good. What is actually needed is a way to filter exceptions, via a policy, without actually catching them and so triggering the execution of finally blocks, unless we find a policy that tells us the exception is safe to recover from. The CLR team blogged about this recently:
Are shared properties accessible from a COM exposed .NET assembly?
Dim appExcel As Object Dim objAppSingleton As Object Set objAppSingleton = CreateObject("Pitchbook.CommonUtils.Application.PitchbookAppSingleton")[code].....
The line appExcel = objAppSingleton.CurrentPitchbookExcelApp gives the error:Run-time error '438': Object doesn't support this property or method
I am writing a VB.NET app that has a piece which needs to send a small command to comm port 2 and get the return result. The problem is .NET doesnt have any support for serial communication seems like.
I just need to send the command "headtype" and get the result.
I have been again blessed with legacy code made (presumably) with vs 2008. It's a Visual Basic project with a dependency to SQLite. The actual problem is that it is needed to install and run on Windows 7. Now, I have VB 2008 express in which I opened the project and tried to run it. It threw an exception which was most likely due to the fact that SQLite.dll doesn't support Windows 7 (and/or 64 bit environments). The exception was System. BadImageFormatException. (ddl version was 1.0.65.0)
I read somewhere in the internet that in order to run it in Windows 7 you need to have newer version of it. I downloaded it and managed to change the reference to newer one. Now in the SQLite site it says it requires .net version 3.5 or 4.0. I know that I can change the target framework to 3.5 or even 4.0 but do I need to change some of the old references in the project properties? All the references seem to be to 2.0 libraries. Like System 2.0.0.0 and path to X:windowsMicrosoft. NETFrameworkv2.0.50727System.dll. Does this actually mean that the application is using .net 2.0 although it target framework would be 3.5 or 4.0?
And most importantly do I need to convert my application manually or by using some tool to .net 3.5 or 4.0 in order to get it running with new SQLite dll which requires 3.5 or 4.0?
I want to be able to add a range and get updated for the entire bulk. I also want to be able to cancel the action before it's done (i.e. collection changing besides the 'changed').
I have a problem with a global variable in VB.Net.In one sub (triggered by a button) I create objects and store them into a global variable (an array). After that I create a table (DataGrid).With a second button another sub is triggered and tries to use the array from the global variable, but it seems to be empty.Here is the code:
<script runat="server"> Dim array_datensatz(12) As Datensatz Sub submit1_click(ByVal Sender As Object, ByVal E As EventArgs)[code].....
i am using file system watcher for service when a xml file is come in i processed the xml file and set Processed = True but this variable value doesn't change untill all file created..
I compiled some VB6 code on my Win7 x64 machine and the result .exe will not run correctly on any other machine. VB6 code is just a new template .exe file with one button, a reference to "Microsoft ActiveX Data Objects 2.6 Library" and the following code in the button press event: Dim db Set db = New ADODB.Connection It runs correctly on my machine, but no others (even other Win7 x64 machines) (Update: I found TWO other users where it runs and one of them is Jeff Atwood!, but most machines have the same problem)
Why if you pass an object as byVal into a method is it then treated as if it were byRef? I know you're only passing the reference across when you pass an object variable but why doesn't VB force you to decalre the header as byRef?
Id'like to pass some variables (string and integers) to a class, and when I call a method of that class, it has to change the original variable.I know it was not impossible in C#, but I'm using VB2010, I made a C# project into my solution, but methods using pointers are hidden into VB. How can I make that kind of change?
An example:
Sub ChangeValues() Dim A As Integer = 1, Str As String = "Start String" Dim X As MyClass(A, Str) X.ChangeInt(2)
have a 2d array of structures that holds about 5 or 6 details on each cell. The array size will not be known at compile time so I am using ReDim to resize it. I also have a list (think I have it as an arraylist actually but shouldn't matter really) that I would like to hold a pointer to one of the 2d array elements (as well as some other info). The list is a much smaller subset of the 2d array. The reason I am doing this is that the list needs to be sorted based on some data in the 2d array that will be changing. I don't want to have to search through the list each time to update the values as these lists and arrays can potentially be very large.
Maybe there is a better way to handle this but even if there is I would like to know how to simulate pointers in VB.Net. I know there are IntPtr's and references that I could probably use but I have no idea how to do it with dynamic arrays of structures. I'm familair with pointers from C++ but this is the first time I have tried to use (or simulate since there seems to be no real support for them) in VB.Net.
Not sure how clear that was so here are some snippets of the data types involved and some initialization.
Code: 'structures that are in the 2d array Structure SearchNode
I'm looking for something similar to using vectors and pointers that I've used before in C++; unfortunately, it doesn't seem like there's an equivalent function in VB.net.What I have is a copy of the array behind a multi-line Rich Text Box, and I need to separate the words from each line (or element of the array) so I can analyze each one separately.In C++ I would do something like this, so I could continuously expand as needed:
i am new to commercial programing (and this site) I am currently studding Computer science at a university and i have hit my First roadblock.I am currently developing an application that displays a Table on one Form1 in a Read-Only format and a second Form2 which will only be displayed if after selecting a row on the Grid-View of Form1 you press an Edit button.We are doing that to avoid the User editing the DB in large. The Form2 is populated by a details view of the Table with no controls to change row on the table.What i am trying to accomplish is passing the information of which row was selected in Form1 to Form2 thus making it the current row and subsequently the only one been edited. Currently most things work but as soon as Form2 shows (Form2.show()) it will only display the first row of the database.I want to know if there is a way to "sync" the two indexes.
I'm looking to make a simple web traffic sniffer that will automatically reply toauthentication requests from a predefined source, but I'm not entirely sure how tostart/what I am looking at my self here.I guess it's easier to explain if you have a short backstory;I use WebDAV, but Windows does NOT have good support for this (lacking Basic auth support, and Digest support being flawed at best), so you are forced to manuallyauthenticate with a username and password every time you open a file, when you start your computer or a word document (for example) loads resource such as images (imagine writing yoru username and password for every image in a powerpoint!).
have an app where the user can select to search websites I have "Hard-Coded" into the app and select categories and sub-categories to search within those websites.What i need is to figure out how to take a user defined search query (Example: The Holy Bible King James Version), then search the relevant websites (behind the scenes) then output the results something like a google or bing search, then allowing the user to download directly their search query
I am in the process of writing a tool to manage DHCP servers using the DHCP Server API. Its an unmanaged DLL so using it is a PITA at least for me it has been.Currently I am stuck trying to enumerate the IP ranges in a particular IP subnet. I am able to access an array of structures but I have only been able to access the first structure in the array of strucutres.Using this I can sucessfully access the first structure in the array.
Dim element_info_array As DHCP_SUBNET_ELEMENT_INFO_ARRAY Dim element_data_ptr As LPDHCP_SUBNET_ELEMENT_DATA ... element_data_ptr = DirectCast(element_info_array.Elements, LPDHCP_SUBNET_ELEMENT_DATA)
However when I use this to try and loop through them one at a time it does not work. The ptr returns 0 is null.
Dim element_info_array As DHCP_SUBNET_ELEMENT_INFO_ARRAY Dim element_data_ptr As LPDHCP_SUBNET_ELEMENT_DATA For i = 0 To size
[code]....
The sizeof for DHCP_SUBNET_ELEMENT_DATA could be off due incorrectly setting up the union structure for it. I was not sure how it define it so that only the first ElementType and one of the other components is avalible at any given time. It wont even read the first pointer though so that has not even come into play yet.
<StructLayout(LayoutKind.Sequential)> _ Public Structure DHCP_SUBNET_ELEMENT_DATA Public ElementType As DHCP_SUBNET_ELEMENT_TYPE
How Should I Use Diffrent Types Mouse Pointers in .Net for Each Form? How Should I Play a mp3 sound File From "D:My Locationsound.mp3"? How Should I Create an Set up File in VB.Net 2008? How Should I Make a Form Shaped Round? How Should I Use The Mouse as Mouse Touch Event?
I'm trying to call C code in the form of DLL's from Visual Basic. When I do everything passed by value I have no issues. But what I really need is to return multiple pointers to arrays of sizes I don't know at compile time (so I'd have to dynamically allocate that memory). For instance
[Code]...
Here the array sizes are hardcoded but that's for the simple fact I didn't want to copy my whole algorithm over, in my actual code I wont know the array sizes at compile time. So my questions are these:How do I make the function declaration in Visual Basic 2008? How do I free up the memory in Visual Basic that these pointers point to?
My application uses a third party API. This API uses a few functions that returns a value by reference as one of the function parameters. Problem is according to their documentation, the value I am trying to get out of this function is a string pointer.
So if that made no sense, heres an example of the syntax of the function as shown in their documentation: long ExampleFunction(long ID, long PropNum, char* name, long MaxStringLength) Input Parameters: ID, PropNum Output Parameters: name, MaxStringLength
Thats pretty much all the info I've got. Obviously they are not using VB.Net, looks like C to me. I want to get the name output parameter and work with it, but once I get this value, I cant change anything. I know this is because its a pointer (reference type?) but I am still at a loss as to what to do.
I am using these API functions for my project where I am handling 3 unmanaged DLLs of two external apps, basically all it does is to carry data back and forth between these external applications. The project needs a lot of use of pointers, passing pointers and reading/writing to memory so both applications can talk to each other.
Declare Function HeapAlloc Lib "kernel32.dll" _ (ByVal hHeap As Long, ByVal dwFlags As Long, ByVal dwBytes As Long) As Long Declare Function HeapCreate Lib "kernel32.dll" _
[code]....
set of windows API functions for allocating memory, reading and writing to allocated memory, and other required functions to generate required arguments to pass to these API calls?I am up to where I am allocating memory and getting pointer, but I don't know how to go about reading, writing, passing pointers, finding data lengths and reusing memory.
Correct the problems with this function, and then extend it so that it also returns a usable array of pointers to some structures.
The extended version of this function should: Maintain the same "char *" return type which returns a pointer to a usable, for storing a C string, memory buffer.
In addition, also return a usable array of pointers to structures. This array of pointers is of variable and random length, which must be obtained using GetNumberOfSomeSeqsToGenerate(), which is called, ONLY, from within this new extended version of the function.
The type of these structures and the function that should be used to get these structures are defined as follows:
typedef struct { char* name; /* '\0'-terminated C string */ int number; } SomeSeq;
I'm trying to calculate tip using radio buttons and use them to select the percentage but the variable "tip" doesn't transfer over to the next sub and lblTip.text keeps coming up as 0 Here's my code: