Calling Function From Field In Table?
Jul 2, 2010
I have a table of reports and queries that users of my application can run. I now have a need to allow them to execute a Function and I'd like to treat the function like I have my reports and queries by listing it in a table with a 'friendly user title' attached to it and then when the code executes, it would reference the name of the function that I have in another field of that same record. I can't seem to figure out how I can get VB to understand and treat the value in a field as the name of a function and execute it.
Table
Friendly Name Object Name Object Type
Report of Costs rptCosts Report
List of Costs qryCosts Query
List Active Emails ActiveEmails Function
In my current code I check to see what type of object it is that they want to execute and use either DoCmd.OpenReportor DoCmd.OpenQuery. Now I want to execute a Public Function that I have created that will open its own form to display the resulting requested information in.
View 3 Replies
ADVERTISEMENT
Feb 24, 2010
I am building a data based application using VB 2008 an SQL Express. I need to create textboxes on my form using code, (With & End With) method. I need a simple code string that will allow the app to check if the field to wich the textbox wil be databound is Nul, If so the textbox will not be created.
View 8 Replies
Feb 17, 2011
I'm currently working with a client's VB.Net code, which was developed for them by a small development shop a few years ago and which they purchased and have been maintaining and uprgrading since. This client's primary developer is out on indefinite (likely permanent) medical leave and I'm now filling in until they bring in a full timer (as I'm a contractor here). My current task is to add some functionality to a the VB.Net code they purchased. I'm finding practices and techniques in the code that absolutely baffle me and can't make the code do what I want. I'm starting to wonder if it's me and was hoping to get some thoughts on the code I've encountered.
For example: Setting a variable to accept the result of a function by calling the function with many parameters, clearing the parameters in the function, setting them to some value, calling another function with those new values, then never using the values returned by the functions. I'll add a code snippet in the first comment since this is already getting long.
View 9 Replies
Sep 14, 2010
I have a function where I am performing a lot number of database operations inside a Sub. The operation when called directly like:ExecProcess()
takes about 11 seconds to run.However, if I create a Delegate, and call the sub using BeginInvoke(), the very same process takes over 40 seconds to execute.Here's the threaded code:
Protected del As ProcessDelegate
Protected Delegate Sub ProcessDelegate()
del = New ProcessDelegate(AddressOf SELocal.ExecJob)
Dim cb As New AsyncCallback(AddressOf Me.ExecJobComplete)
del.BeginInvoke(cb, del)
Anyone know what may cause a function to take longer inside a new thread, rather than calling directly?
View 2 Replies
Mar 30, 2012
I am having a problem with the BackOrdered Function of my program. I can`t get it to say anything but 0 when I run the program. Another problem I am having is the input box pops up like 6 times and it`s only suppose to once. [Code]
View 9 Replies
Jul 22, 2010
I am creating a database in VB.NET for a movie rental place. I currently have three forms;
Member Information
DVD Information
Borrow DVDs
What I would like to do is when I am viewing a member's details, if I click a button 'Borrow DVD for Member', the member's ID number transfers over to the Borrow DVDs table in the Member ID which also would hold some information from the DVD Information table, but I'm sure if i can figure out how to do this firstly, I will be able to apply the same rule and work it out myself.I have been trying to use a query statement like;
INSERT INTO [Borrow DVDs].[Member ID] [IN goodstuffvideos.mdb]
SELECT [Member Information].[Member ID]
FROM [Member Information]
but that has been coming up with error codes and completely not working.
Borrow DVDs table fields are: Borrow ID, Member ID, DVD ID Number, Hiring Fee, Borrowing Limit?
DVD Information table fields are: DVD ID Number, Title, Rating, Hiring Fee, Borrowing Limit Member?
Information table fields are: Member ID, Family Name, Given Name, Address, Town/Suburb, Postcode?
The error coming up is; Error in INSERT statement. Unable to parse query text.And under that it says The query cannot be represented graphically in the Diagram and Criteria Pane.
View 1 Replies
Jul 8, 2009
I currently have this working already for one of my combo box's, but when i try to use the same code i get this error ''There is no row at position 6.'' . The are 2 fields in the table asset_type_id, asset_type_name', im trying to dispaly the values in a combo box for the field 'asset_type_name.
the code for ' Friend Sub RetrieveCustomerInformation2()' works but the other friend sub throws the error.
Imports System.Data.SqlClient
Imports System.Data
Imports System
Imports System.Data.OleDb
[Code]...
View 3 Replies
Feb 23, 2011
I have a query that I have to run that requires me to get rows from a table based on the value of a field in another table (which I have gotten earlier). I currently have it done like this (simplified).
[Code]...
View 1 Replies
Feb 7, 2010
with .net 2008 exp + MySQL 5.0
my code is like this;
Dr_cug.Read()
cug = (Dr_cug.Item(0).ToString)
Dr_cug.Close()
error msg is; Invalid attempt to access a field before calling Read()
i have called the read here what's going wrong please
View 7 Replies
Oct 3, 2011
I have used the PInvoke Signature Toolkit to create VB.NET function definitions for three fairly simple C functions contained in an external DLL. The problem is that two of the parameters are structures so pointers need to be sent and one structure (fileview) is undefined.
OpenFileView(filename, &fileview_ptr)
ReadFileInfo(fileview_ptr, &fileinfo_ptr)
The structure of fileinfo is defined so I can create a structure definition in VB.NET and create an IntPtr to that structure with Marshall.AllocHGlobal. And then I can use Marshall.StructureToPtr to copy the data and do the inverse when the data is returned.
[Code]...
View 1 Replies
Dec 7, 2009
I'm having some problems calling a C function from a DLL. The function is returning -101 which translates as a "bad parameter". The values I am passing have been returned from another, successful function call, so my current assumption is that I've built the structure incorrectly.The function definition is:
int sm_switch_channel_input(struct sm_switch_channel_parms *switchp)
Parameters
*switchp (a structure of the following type):
typedef struct sm_switch_channel_parms {
[code].....
View 2 Replies
Mar 18, 2009
in a DLL that takes a pointer to a structure as a parameter.The C and VB code is as follows.Am I passing the structure in calling the DLL correctly? I am asking because the API call returns a valid error code indicating error opening the com port specified. I tried all valid ports (com1 on a Vista 32 machine with a USB-Serial device and com1 defined in device mgr, com1 and com2 on a desktop with winxp and 2 real serial ports).I dont have the code for the DLL and cannot debug into the DLL code.
C code
typedef struct _SETUPPR {
CHAR Port[5];
[code].....
View 1 Replies
Mar 15, 2011
I'm sure this is a pretty simple question but I can't seem to find the answer on Google. Say I've got a function that does some stuff and returns a string. I can assign its return value to a variable:
Dim result As String = MyFunction()
But sometimes I want to perform the actions within the function but I don't care about the return value. I know I can simply call the function from code.
Sub Main()
' Code
MyFunction()
' More Code
End Sub
This works and does exactly what I need it to. My question is - are there any issues or pitfalls in doing this? Particularly I want to make sure I'm not introducing any performance or memory leak issues.
View 4 Replies
Apr 9, 2010
The function is something like this: "function recieveFindPlayerResponse(displayString)"Now, how can I call it. I was trying this:Call AxShockwaveFlash1.CallFunction("_root.recieveFindPlayerResponse(displayString)")And before I had this, I had a Call function which defines displayString. (Works, as I've tested it before, and no error is given to this.)Now, how can I call a function like the above?
And example of what the code looks like from ******* swf decompiler is:
function recieveFindPlayerResponse(displayString)
{
[code].....
View 4 Replies
Mar 17, 2010
in VVB.net I have a string that contains the name of a function, say dim funcstr as string = "MyFunc1". How do I call the function or sub whose name is contained in the string funcstr (in this case, MyFunc1)?
View 9 Replies
Feb 28, 2012
going to need to call unction within a FoxPro program. I believe within my VB program I will need to create a service which will need to cal
View 7 Replies
May 8, 2012
I have an aspx page populated with data from an access database using this code:
<asp:datalist id="bookData" runat="server" RepeatDirection="Horizontal" RepeatColumns="3">
<ItemTemplate>
[Code]....
I would like each entry of data to have a button associated with it that could call a server function to submit data to a database. I currently have the button implemented, but no idea how to go about calling a function that would be able to detect what button was clicked.
View 1 Replies
Jun 14, 2012
i have this question i was trying to find a way to call a javascript function from asp controllers and i did here is the code :
<script type="text/javascript">
function hello() {
alert("hello world")
[Code]....
and i want to call it from a javascript function so it will be like controller----call---> javascript ---call--->code behind
View 3 Replies
Sep 27, 2011
I've designed a Windows Service in Visual Basic 2005 that needs to call some functions from a DLL written in Delphi 5. If I try to add this DLL as a reference, I get this error:
"A reference to 'C:ProjectsServiceProMDPUpdateServiceMessageStubApplicationSPHost.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component."
I assume that it is just not possible to add this DLL as a reference to my VB2005 project, since the DLL was written in an old version of Delphi, correct? This isn't a big deal, as I can just use the DllImport function from System.Runtime.InteropServices, but if it is possible, adding it as a reference would be preferred.
My other question is, how would you be able to call a function from the DLL using DllImport, if the function you are trying to call takes a Delphi record data type as a parameter (if this is possible)? If possible, would I need to pass each field in the record separately or would I be able to define a structure in my VB app that mirrors the record definition in the Delphi DLL and pass that? Or, would it be best if I just created another function in the Delphi DLL that took various string/integer/boolean/etc. parameters that I could call from VB that would then call the original function in Delphi? I tried searching the internet for this specific question, but I couldn't find anything that looked useful.
[Code]...
View 1 Replies
Jun 2, 2010
I have an XML file with a list of tasks to be executed. One of the elements of the XML file is funcName (function name), which is the name of a function to be executed in my Visual Basic.NET application (v4).I can retrieve the string name of the function, but how do I go about running it? I have two Class files, GUI and DISP.[code]
View 2 Replies
Sep 2, 2011
Is it advisable to call a function from another form?Does it have any side effects on the system while running, like more process will consume?I have a function that will set the background in a form, it will make the image stretch, backcolor transparent and will set the picture. If I will use that function in other 15 FORMS I can minimize my code.
View 9 Replies
Sep 24, 2010
I have an 100 aspx files with one module file for code. All these aspx files have the same backend function, so i created on public module for all these files to access. These files are in the same folder. But for some reason the aspx files cannot access the function from that module.
mod1.vb Code (.vb file)
Public Module Allinone
Sub Allinone_Load(ByRef Page As Web.UI.Page)
[Code]....
I am at a roadblock of why the aspx files wont read this module? Also all these files are in the same directory
View 1 Replies
Nov 6, 2009
I have a couple of threads running. One is a trigger which picks up a system event, the other processes stuff. When the trigger picks up the event I want it to notify the processor thread to do stuff. The threads are both started within the same class and can access the thread-object of the other thread. How do I set up the function call though?
View 10 Replies
Jun 2, 2010
Question: I want to call a generic function, defined as:
Public Shared Function DeserializeFromXML(Of T)(Optional ByRef strFileNameAndPath As String = Nothing) As T
Now when I call it, I wanted to do it with any of the variants below:
Dim x As New XMLserialization.cConfiguration
x = XMLserialization.XMLserializeLDAPconfig.DeserializeFromXML(Of x)()
x = XMLserialization.XMLserializeLDAPconfig.DeserializeFromXML(GetType(x))()
x = XMLserialization.XMLserializeLDAPconfig.DeserializeFromXML(Of GetType(x))()
But it doesn't work.I find it very annoying and unreadable having to type
x = XMLserialization.XMLserializeLDAPconfig.DeserializeFromXML(Of XMLserialization.cConfiguration)()
Is there a way to call a generic function by getting the type from the instance ?
View 5 Replies
Oct 9, 2009
wondering if there was anyway I could call a function of an external program. Ie.My App:Call Reset()External App:Reset()My.Settings.Rese
View 4 Replies
Oct 26, 2011
Is it possible to call a function within an asp.net web application from outside that application e.g. with VB.net? If so it would be great to see a hello world type example.
For arguments sake lets say I have my function "helloworld" in a class file within web application: [URL]
My ultimate goal is to enable some reliable / robust scheduling of functions within asp.net. I have read multiple examples about using web services / custom services running on the server etc but I don't really get the implementation.
View 2 Replies
Jan 3, 2012
I'm having trouble accessing a DLL function that uses a HANDLE as a return type.This is the signature of the function within the DLL:
HANDLE netagentsearch(int nPort, int *nError); I am able to access the function fine with C++.
typedef HANDLE (*funcnetagentsearch)(int nPort,int *nError);funcnetagentsearch Search;Search = (funcnetagentsearch)GetProcAddress(hGetProcIDDLL, "netagentsearch");HANDLE test = Search(7, &error);
I understand that vb.net doesn't have a HANDLE type, but as far as I knew, you could use IntPtr instead. This is the code in vb.net: <DllImport("netclient.dll", EntryPoint:="netagentsearch")> _Public Shared Function GetDeviceList(ByVal nPort As Integer, ByRef nError As Integer) As IntPtr End Function Dim test As IntPtr = WirelessLedCtrl.GetDeviceList(7, error) The error I receive when trying to run the VB.NET code is:
DLLImport_Wireless.WirelessLedCtrl::GetDeviceList' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
Is there something I am doing wrong?I just solved a major problem that I've been working on for 4 months, so if I end up having to use C++,
View 2 Replies
Mar 21, 2012
In my application I'm trying to invoke a function from an external DLL (this DLL is compiled in C++)I have this code to declare the DLL function:
Code:
<DllImport("{DLLPATH}", CharSet:=CharSet.Auto, SetLastError:=True)> _
Public Shared Function functionName(<MarshalAs(UnmanagedType.VBByRefStr)> ByRef Name1 As
[code]....
View 2 Replies
Jul 5, 2009
I have this simple function (below) that randomizes number between 1 to 10. This function works well, except when Random() returns 5, which means intLot=5, randomizeAgain = true, and then the same function RandomizeNo will be called to randomize again. (refer the code below)
Even the new value of intLot equals other than 5 next time, say 4, the funtion returns 0.
I have no idea why. Function RandomizeNo(ByVal totalLot As Integer) As Integer
[Code]...
View 4 Replies
Dec 14, 2009
The following two statements seem the same to me but the first throws a design time error, and the second does not. The first one is passing the first parameter in hex and the second passes the first parameter as its decimal equivalent.
Public Shared ReadOnly Test As New Guid(&HCC58E280, &H8AA1, &H11D1, &HB3, &HF1, &H0, &HAA, &H0, &H37, &H61, &HC5)
Public Shared ReadOnly Test2 As New Guid(3428377216, &H8AA1, &H11D1, &HB3, &HF1, &H0, &HAA, &H0, &H37, &H61, &HC5)
Here is the error associated with the first statement:
Error 1 Overload resolution failed because no accessible 'New' can be called with these arguments: 'Public Sub New(a As Integer, b As Short, c As Short, d As Byte, e As Byte, f As Byte, g As Byte, h As Byte, i As Byte, j As Byte, k As Byte)': Constant expression not representable in type 'Short'. 'Public Sub New(a As UInteger, b As UShort, c As UShort, d As Byte, e As Byte, f As Byte, g As Byte, h As Byte, i As Byte, j As Byte, k As Byte)': Constant expression not representable in type 'UInteger'.
View 1 Replies