Marshal Attributes To Be Passed As An Argument In This Declare Statement?

Sep 24, 2010

Marshal attributes to be passed as an argument in this Declare statement? [code]...

View 3 Replies


ADVERTISEMENT

Forms :: Add The Argument For The ID In The Labels Tag To Be Passed To This Sub?

Feb 9, 2011

I have created a control, similar to an image combo, but a bit different. Any how, each of the labels that contians text to be clicked has an ID in their tag, that i wish to read. I have a sub routine called CBO_Click() which has the same arguments as a normal label click. How can i add the argument for the ID in the labels tag to be passed to this sub.

View 2 Replies

Derive Address Of A Function That Is Passed As An Argument?

Nov 26, 2009

ok basically i've got a delegate ByVal function_to_execute As dele0 but instead of invoking it, i wish to add it to an eventhandler

Public Sub test(ByVal function_to_execute As d0)
Dim t As Timer = New Timer()
AddHandler t.Tick, AddressOf function_to_execute.address

[code].....

View 4 Replies

Run A Statement That Has A File Path As Argument?

Dec 2, 2008

I'm trying to run a statement that has a file path as argument. It works, unless a space is present in the file path.

The code is:

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "xcacls.vbs \" & hostname & "C$program files estmap estfile.txt /G BUILTINeveryone:r /f /t /e{enter}"

I've tried everything I can think of, but it's not working! I've seen other threads with this problem, but they're never posed at with the sendkeys function.

View 1 Replies

'As Any' Is Not Supported In 'Declare' Statement

Sep 3, 2009

[Code]...

What needs to be done to properly declare the function using vb.net

View 4 Replies

Libname In Declare Statement?

Jan 25, 2010

I am using the command

Public Declare Sub subname Lib libname ()
g,
Public Declare Sub test_dllsub1 Lib "C:/path/dllname.dll" (ByRef arg As Double)

[code]......

View 1 Replies

Using A Listbox To Declare A Parameter In Sql Statement?

Dec 23, 2010

I have a list box that allows multiple values to be selected.Here is my query for my gridview

[Code]...

then before the query is run i use to subtract the final , so i dont get an error and i have to use textbox1.text in my query and not the parameter. that is slower and sql injection,

View 1 Replies

Adding A 'declare Function' Statement In VB Using CODEDOM API

Oct 23, 2010

I'm fairly new to learning visual basic. I'm trying to create a program that dynamically generates a EXE file that performs mouse movements and keystrokes. To dynamically generate EXE files, I am using the CODEDOM API for Visual Basic.

[Code]...

View 2 Replies

Insert Statement Error.. "Update Requires A Valid UpdateCommand When Passed DataRow "?

Feb 17, 2009

when the program is already save the data and when the process is on updating the dataset it give me error say's"Update requires a valid UpdateCommand when passed DataRow collection with modified rows."The error occur at the line in bold letter in the codes below..

Dim classgroup As String
classgroup = ""
If Me.ClassComboBox.Text = "Key Project" Then

[code].....

View 4 Replies

Can A Generic List Of T Be Passed To Function Similar To Way An Array Is Passed?

Mar 23, 2012

I want to pass a List of T where T is an object I've created that has about ten properties (strings, dates and integers).The lst passes to the function successfully. I am also passing an New T of the Object (itm as T).I can see all the values (see image below), but because it's generic I cannot seem to retrieve the property values and I cannot figure out how to iterate through the properties of each itm as they are retrieved in the For Each.[code]

View 10 Replies

Sql Server - Assign The Value I Queried To A String Which Is An Argument In A Procedure If The Argument's Data Type Is An Object?

Dec 5, 2011

I made this procedure re-use a select query:

[code..]

And I use it like this if I would want the selected value placed in a textbox and it works fine

[code...]

However if I want the value to be passed in a string like so:

[code...]

The string ends up having an empty string value. How do I assign the value I queried to that String?

View 2 Replies

USB Via .NET 2 Notifications And Marshal?

Jan 14, 2009

I'm a VB6 programmer who was forced to upgrade to Visual Studio 2005 Version 8.0.50727.42 .NET Framework Version 2.0.50727. I am trying to write a call-back which will intercept a Windows message for when our USB HID device is plugged or unplugged. We have a custom .dll which handles the majority of the HID interface. I just need to call a few API's to connect to the device. I can connect and communicate.

I am looking at USB Complete Third Edition. The code examples do not compile. I'm unsure if this is because of the .NET version 2 or the 2005 dialog of VB. I cannot resolve "StructLayout..." statements, but the program appears to be working without them. I cannot get any "Marshal." statements to compile, which is where I am finding it difficult to get around.

[Code]...

Although OnDeviceChange() is being called six times, both IF statements fail. m.msg is 0x219, which is Device Change. m.WParm is always 7, m.lParm is always 0. And, this is where I'm stuck. m.lParm should be a pointer which gets me to the device path? Don't know what 7 is.

So, maybe I'm not registered to receive the proper messages from the device (or I'm looking in the wrong place). The missing step might be to call the RegisterDeviceNotification() API. This book is telling me to use frmMy.Handle declared globally as Friend frmMy As frmUSB - that gives me a null reference runtime error, so I swapped in Me.Handle for the first parameter to RegisterDeviceNotification(). It likes that. But, then it has heartburn with the buffer pointer - not so easy to resolve in Visual Basic. The call wants a LONG. I have DevBroadcastDeviceInterfaceBuffer, which the book says to use Marshal.AllocHGlobal(Size) and Size is Marshal.Sizeof(DevBroadcastDeviceInterface). Neither Marshal statement compiles and I'm not sure if it was removed in this version of .NET? Anyone? I really don't need a dynamically allocated buffer. This is quickie VB app for a single USB device.

Can anyone tell me how far down the rabbit hole I am and what I'm missing. I can tell when something changes to some USB device. I have a handle to that device supplied to me by a custom API library - probably is the HID handle.

How can I setup to receive a message when my HID USB device is unplugged or plugged in?

View 6 Replies

Marshal An Array With Fix Lenght?

Feb 20, 2012

I need an array with fix String lenghts and fix rows... I do this...

Imports System.Runtime.InteropServices
Public Class Class1
Public WPFFunktion As String

[code]....

View 1 Replies

C++ - Why Do C# And VB.NET Implicitly Marshal Char* Differently

May 22, 2010

What is the most timers you have used in an application? I think the most I have ever used is 2.In another forum this question was asked. "I have a Timer ... I have a situation where I want to run the code in the Tick event ONLY ONCE not on the interval i have the timer set too."

I responded with Timer1_Tick(New Object, New System.EventArgs) Which led to this "The 'sender' object is VERY important when you have more than one Timer being handled by the Tick event procedure. This is because in a multi-timer tick event procedure, the only way your program knows which timer just fired is by querying the 'sender' object.When you use code like this you are putting nothing into the 'sender' object, so that if you were ever going to query it a 'kaboom' is going to happen.""...this 9 timer Tick event handler job done. Remember, all that is required is the correct timer name gets put into the ListBox." "The need for multi-timers to be handled by a single Tick event handler happens all the time. How would a real life programmer handle this? "Oh, to test the "kaboom" theory I wrote this and ran it overnight successfully:

[code]...

View 33 Replies

Marshal Back To Main Thread?

Dec 15, 2009

I am using a COM library in my VB.NET app that has an asynchronous execution method and signals my application via an event when it completes. The event handler is on a different thread from the calling thread. I want to invoke another execution on the main thread when I receive the completion event. If I call directly in the event handler for another execution it starts on the new thread. How do I marshal back to the main thread. This is done in a dll not in a form.

View 3 Replies

Marshal Variable Length Array?

Jun 8, 2010

I'm trying to call the GetInterfaceInfo Windows API - it accepts a structure as one of its parameters and this structure has a member that is an array. The API populates the contents of the array when it is called and there can be any number of items in the array. How can I define such an array in my structure?

If I just use a normal .NET array like so then the program just crashes (no exception thrown)

<StructLayoutAttribute(LayoutKind.Sequential)> _
Public Structure IP_INTERFACE_INFO
Public NumAdapters As Integer

[Code]...

and this works fine, but the problem is I have to define the SizeConst attribute as you can see to something large (64 in this example) so that the API doesnt fail because the array wasnt big enough. Firstly this is a waste of memory as in most cases the number of items the API sticks in the array will be less than 10, but secondly if there was ever a case where the API wanted to put more than 64 items in then it would fail.

Using ReDim to set the length of the array at runtime seems to have no effect, and that SizeConst attribute has to be set to a constant value so there's no way I can dynamically set it.

View 8 Replies

UI Marshal Class With INotifyProperty Changed?

Jan 24, 2010

creating a business layer in a .dll which at the moment is being used on a windows forms application. I have some objects with properties that use iNotifyPropertyChanged to update the UI which has all been working fine. My problem is tarted to explore using multiple threads and ing a cross-thread error because the properties are being changed on a different thread to the UI and iNotifyPropertyChanged is attempting to update the values (shown in labels) on the UI thread... shows the best way to solve my problem. The .dll will never know what Forms application is using it so I really dt want to hard code references into the objects. From what I gather this code allows you to register a form with the .dll and then add the invoke to OnPropertyChanged to avoid any threading issues. Is this correct?

View 5 Replies

VS 2008 AccessViolationException When Using Marshal.Copy

Dec 24, 2010

I get an AccessViolationException using this code (attempted to access protected memory, this is often an indication that other memory is corrupt) on the line in DoWaitNotify that copies the pixel data back to the location in memory. In my experience, that usually means that the array is too large, but it all seems to check out. Does image data expire after a certain time or something?

Public Class Form1
Private Const NUM_THREADS As Integer = 3
Private Original As Bitmap

[Code]....

View 4 Replies

VS 2010 Marshal.ReadInt32 -> AccessViolationException?

Jan 11, 2010

VS 2010 [RESOLVED] Marshal.ReadInt32 -> AccessViolationException

View 6 Replies

Contrast Algorithm C# Pointer To Marshal.copy

Apr 28, 2012

I tried to translate this code to vb.net using Marshal.copy but I can't get it to work

for (int y = 0; y < bitmapdata.Height; y++)
{
byte* destPixels = (byte*)bitmapdata.Scan0 + (y * bitmapdata.Stride);

[Code]...

View 1 Replies

.net Equivilent Of Ruby's Marshal - Object Save/load?

Jun 20, 2012

I'm just needing a simple bit of code for vb.net that will allow me to marshal an object into a string, allowing for the saving and loading of this string so I can save my classes, needs to be simple and easy!

View 1 Replies

Office Automation :: Marshal.GetActiveObject Preventing Excel From Being Released?

May 17, 2010

I've created a simple Windows Forms Application and the idea is I want to identify all instances of Excel, save any open workbooks to my desktop and close all the Excel instances down.[code]I'm pretty new to this C# business so hints on the following two possible issues I've identified would be much appreciated:The ForEach loop doesn't seem to be successfully looping through the XlApp.Workbooks collection as I was hoping.
It seems that I can't quit each Excel application which, with my current code structure, is causing an infinite loop. My suspicion is that Marshal.GetActiveObject() is locking it up and preventing it from closing?If nothing obvious jumps out then I might try the alternative method by Andrew Whitechapel mentioned and linked to on this thread.

View 11 Replies

Marshal.Copy Error When Running Program, Complains About Protected Memory?

Dec 5, 2010

I get this error on this line: System.Runtime.InteropServices.Marshal.Copy _

(Scan0, Data2, 0, Data2.Length)

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

I also sometimes get an error on this line:

Dim dc1 As IntPtr = CreateDC("DISPLAY", Nothing, Nothing, CType(Nothing, IntPtr))

What I'm trying to do is take a screenshot and then read the colors of pixels. I currently have a working vb.net copyfromscreen method but it's SLOW and using 100% cpu usage.

[Code]...

View 3 Replies

Object Array To Byte Array - Marshal.AllocHGlobal Fragmentation Query?

Jun 14, 2011

I didn't think it fair to post a comment on Fredrik Mörk's answer in this 2 year old post, so I thought I'd just ask it as a new question instead..NB: This is not a critiscm of the answer in any way, I'm simply trying to understand this all before delving into memory management / the marshal class.

In that answer, the function GetByteArray allocates memory to each object within the given array, within a loop.Would the GetByteArray function on the aforementioned post have benefited at all from allocating memory for the total size of the provided array:

Dim arrayBufferPtr = Marshal.AllocHGlobal(Marshal.SizeOf(<arrayElement>) * <array>.Count)

I just wonder if allocating the memory, as shown in the answer, causes any kind of fragmentation? Assuming there may be fragmentation, would there be much of an impact to be concerned with? Would allocating the memory in the way I've shown force you to call IntPtr.ToInt## to obtain pointer offsets from the overall allocation pointer, and therefore force you to check the underlying architecture to ensure the correct method is used*1 or is there a better way? (ToInt32/ToInt64 depending on x86/64?)

*1 I read elsewhere that calling the wrong IntPtr.ToInt## will cause overflow exceptions. What I mean by that statement is would I use:

Dim anOffsetPtr As New IntPtr(arrayBufferPtr.ToInt## + (loopIndex * <arrayElementSize>))

I've read through a few articles on the VB.Net Marshal class and memory allocation; listed below, but if you know fo any other good articles I'm all ears![URL]..

View 1 Replies

SQL Statement Doesn't Work - INSERT Statement Works Fine In The Form Load But Not In The Button Click Event?

Oct 14, 2009

See

Public Class Form1
Dim sql As String
Dim conn As New OleDb.OleDbConnection
Dim da As New OleDb.OleDbDataAdapter

[CODE]...

The problem, The INSERT statement works fine in the form load but not in the button click event?

View 29 Replies

If <expression> Then <statement [:statement]> Else [statements] In Concrete Form?

Jan 1, 2010

I was convinced that If <expression> Then <statement [:statement]> Else [statements] in concrete form of If a = b Then SayHello() Else SayBye() End has sense. I read article on msdn on If-then-else, but I forgot why I was reading, so I concluded, that snippet above means this

If a = b Then HelloIsSaid : IsNotEnded Else ByeIsSaid : IsEnded But I have tested it now, and I see, that Else without statement is nothing more than decoration. It would be pretty good if it had function I described. Do you think its good request? Or do you know any circumstance where this Else has some function?

View 13 Replies

Making A Next Statement Into A Loop Statement In Visual Basic?

Jun 8, 2009

y friend and I are re-learning Visual Basic, and we are stumped on this bit of code.

For intAsterisks As Integer = 0 To intLine - 1
lblAsterisks.Text = lblAsterisks.Text + "*"
Next

View 6 Replies

Sql - Perform An Inline Select Statement In A LINQ Statement?

Jun 24, 2011

I have the following SQL:

[Code]...

I want to put it (the select count statement) in this LINQ statement so I can get the sales count in my linq statement: Dim TheLeads = (From L In DB.Leads Where L.IsDeleted = False Select L).ToList() Is this possible to do in LINQ?

View 1 Replies

ENV Not Passed To Cmd File From VBS?

Jun 7, 2011

I'm very new to vbs scripting and am trying to set a System envinonment variable which will be used by a subsequent cmd file which is called by the VBS script which created the ENV varible.The vbs script creates the varibale correctly but the called CMD file does not find it. I thought a child process inherited its parent env settings. I understand the child can not change the parents env. why the cmd file does not see the variable, am I using the wrong shell command in vbs to call the cmd file or something?Here is the VBS script that simply sets a System varibale and the CMD file below which attempts to log it.on error resume next

Dim objShell
Dim objEnv
Dim usbDrive
Set objShell = WScript.CreateObject("WScript.Shell")

[code]....

View 2 Replies

Change The Exit Statement To A Continue Statement?

Feb 23, 2009

add an if statement and an exit statement to my do loop that exits when my future value (FV) is greater than 1000, then to change the exit statement to a continue statement so my loop will continue even though my fv is greater then 1000, point is to get this to run even though my if statement doesnt do anything. problem something wrong in my code and an exception error (xception of type 'System.OverflowException' occurred in mscorlib.dll)

so can someone show me where or why I have an error is, what am I overthinking now! I could use a hint, OMG i could use a tutor for that matter

[Code]...

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved