Public Class Form1 Public Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As IntPtr Public Declare Function GetProcAddress Lib "kernel32" Alias "GetProcAddress" (ByVal hModule As IntPtr, ByVal lpProcName As String) As IntPtr
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim hmod As IntPtr = GetModuleHandle(Nothing) 'Work Dim addrs As IntPtr = GetProcAddress(hmod , "TestFunction") 'Not work, always NULL why??
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?
I need to access a DLL function which has a void pointer argument (probably written in C/C++). In VB6 it could be accessed by declaring the argument as 'Any'. VB2008/VB2010 does not know this variable type 'Any'.
I tried instead: Object, IntPtr, UIntPtr, Int32(), Long e.t.c. but there always occurs a compile error or a runtime error.I did a lot of Internet investigation but could not find any answer.
How do I distinguish copying data and a pointer when using a class?E.g. public class myparams var1 as integervar2 as intergerv3 as stringend classmyvar as new myparamsmyvar.var1=1myvar.var2=2myvar.v3 ="hh"othervar as new myparams
I want to copy all of myvar data into othervar in one go.. without doing othervar.var1=myvar.var1 etcusing othervar=myvar" Looks like its just copying the pointer of myvar into othervar? Can I copy all the class data in one go? VB2008 user
I have a Class, which I create an instance of in order to use, however I have a couple of functions (which don't really relate to the instance data) which I want to use when an instance hasn't been created.
Visual Basic .NET (2010)
Example of what I'm trying to do:
' Log a user into the system (this works) Dim hedwig As New CustomSecurity hedwig.Login("username", "password")
is there any way to extend upon a procedure itself?like i want to be able to do the following
Code: public sub test() msgbox(special())
end sub and it should popup a string, let's say "cool", plus i shld be able to use special() in every single sub but if we call special() from a function it should be rejected. how can that be done?
also, we should also be able to do the following
Code: public sub test() msgbox(specialvariable)
end sub whereby specialvariable is accessible by every sub.
I realize that this is a very basic question, but it's been a long time since I've played with VB. Why can't I call the Synch() Sub/Function in my CMMS_SCAD_CLASS class from my Main module? I get the following compile-time error:
'Synch' is not a member of 'ConsoleApplication1.CMMS_SCADA_CLASS.'
Main class:
HTML Module Main Sub Main() Dim meterClass As New CMMS_SCADA_CLASS()
I want to create a function inside my class that will return a boolean on the existence of some data within any structures created with the class.
Public Class MyObject Public Object1 as String Public Object2 as String
[code]....
What I don't know how to do is refer to the object that called the function to get values, including the number of items in the referring objects array.
I am new to vb.net and would like to be able to convert the following code to it's own function - either inside the current module or better yet in a seperate class.This code currently runs in the KEYPRESS event and ensures only numbers, decimal point, 2 decimals etc. are entered and not letters. Works exactly how I want it but would now like it in a function.I need this code in numerous text box controls but I would rather just call it somehow with a function.
I want to create a function (class?) that will have stored the coordinates(values) of my mdiforms, so I can call it whenever I want to dispaly the mdiforms. I want to avoid retyping again and again (in every mdi form) the above Me.Top=5 Me.Left=150 on forms load.
Okay so what im trying to do is make a simple particle system in VB (Yes i know this isnt a ideal setup). Im going to have particles dieing and spawning new ones tho, To do this i need to be able to pass a function to the particle when its created then call that function when it dies. Is there a way to do this by passing function pointers?
Since the string class does not have a Left method, how would you do this in VB.Net. I could use String.SubString(0, x), but the problem with this method is that it throws an exception if the String is not at least x characters long. Should I use the Microsoft.VisualBasic.Left function instead?
Now to working with Visual Studio Solutions, but I am trying something very basic but no joy. So in my project I have a folder App_Code and in this I added a class called Test.vb and added a simple function
[Code]...
But in my Default.aspx page I am struggling to find the correct syntax to call this method. Also it doesnt seem like my Test2.vb class is correctly included in the project because If I make a type the project still builds successfully when it shouldnt
I work in MS Visual Studio 2008, I have a VB.NET Solution which has three Projects, BusinessObjectLibrary (object properties), DataAccessLibrary (object functions such as selectAll, exportToExcel) and WindowUserInterface (UserForms c/w Controls)In my WindowUserInterface (project) I have a form called "rolFormGrid.vb", on this form, I have a DataGrid that gets filled with a function called "selectAll" when the form is loaded, I also have a button that calls the function "exportToExcel" and I have a Progress Bar called "rolProgressBar" ***.
In my DataAccessLibray (project) I have a class called "ROL_Adapter.vb", and in this class resides the function called "exportToExcel" which has all the code to create an Excel Workbook. When this function is being called, it can takes close to a minute to export to excel. We all know how users can be impatient if they do not see anything happening in the foreground when an application is working, that is the reason I want the progress bar.
I want to create a new instance of a class when I click on a button, but I need to interact with members of that class using other controls on the form, so I need the class to have a global scope. I know I could call the new class in formload, but the class creates certain variables that need to be current. If it is done on formload, the variables wouldn't be current, because if the class is created at formload, it would have different info at that time. Surely, there must be a way to create an instance of the myClass from within a sub that is accessible from other subs of the same class.
-edit- nevermind i was lucky and didnt need to change much and have this test working.I am doing a quick test and i need to choose the full path to a function.in C# i can write namespace ABC { class DEF { static string Test() { return "A test"; } } } and can access it with ABC.DEF.Test() i tried
Namespace ABC Partial Public Class DEF Public Function Test(ByVal v As String) As String
[code]....
and i got VBTest.ABC.DEF.Test(). How do i get rid of VBTest which is the name of my project?
Im getting the following error on the code I transleted from C# to VB.NET below (original code can be found here:
Class 'QueryParameterComparer' must implement 'Function Compare(x As oAuthBase2.QueryParameter, y As oAuthBase2.QueryParameter) As Integer' for interface 'System.Collections.Generic.IComparer(Of QueryParameter)'.
I have a class called Customer. It has some property like custID,custName..etc. Inside Customer class I have a function which returns an array of customer.
I wrote a function like this : Public Function InitLoadCustomerDetails() As Customer() sql = "SELECT* FROM tblCust" ds = classDC.queryHandler(sql, "InitCustomerDetails") Dim customerArray(classDC.maxrow - 1) As Customer Dim currentCustomer As New Customer [Code] .....
But it is not returning an array. Just a customer variable?? Public Function InitLoadCustomerDetails() As Customer() Return customerArray End Function Fix this to return an array of customer!!