473,569 Members | 2,793 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Public Overrides Declare Function" possible in any other way?

Hi!

I'd like to dynamically call API functions from different DLLs,
depending on what platform the program runs. Now I'm wondering what the
most simple way may be (without meta code and compiler switches!).

I'd like to call it like that:
Public Sub xyz()
Dim xx As Class1
If _Platform = _yy Then
xx = New Class2
End If
End Sub
The following code is not possible:
Public MustInherit Class Class1
Public MustOverride Function htons( _
ByVal hostshort As Int16 _
) As Int16
End Class

Public Class Class2
Inherits Class1
Public Overrides Declare Function htons Lib "winsock.dl l" ( _
ByVal hostshort As Int16 _
) As Int16
End Class
At the moment I'm wrapping the code in Class2:
Public Class Class2
Inherits Class1
Private Declare Function htons_API Lib "winsock.dl l" Alias "htons" ( _
ByRef hostshort As Int16 _
) As Int16

Public Overrides Function htons(ByVal hostshort As Short) As Short
Return htons_API(hosts hort)
End Function
End Class
But that means that there is exactly the same "Overrides" code in every
class I derive from Class1. This is pretty much overhead, I think.

Does someone know a better way?
Kind regards,

Benjamin Lukner
Nov 21 '05 #1
0 2168

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4046
by: Jef Driesen | last post by:
I need to implement a function to implement the rounding of floating point values. At the moment i have two different implementations, depending on the type of the return value (integer or double). // Integer calculation (fast) int iround(const double x) { return (x>=0 ? static_cast<int>(x + 0.5) : static_cast<int>(x + 0.5) } // Floating...
4
2655
by: MLH | last post by:
The following function declaration confuses me... Public Function IsEMailAddress(ByVal sEmail As String, Optional ByRef sReason As String) As Boolean I tried pasting it and its code into an Access 2.0 module. I was unsuccessful. I had to remove the following... "Public" "Optional ByRef" "As Boolean"
2
4120
by: Tee | last post by:
what's the differences between "Overrides Sub OnError" and "Sub Page_Error" ?
1
6774
by: David Sanschagrin | last post by:
(I previously posted this problem on vb.general.discussion but I've been told that this question is more related to VB.NET than VB6 and so that I should post that here.) I'm trying to call a "Public Shared" function in a dll built in VB.NET from a VB6 program. Whenever I try, I get an error saying that the function doesnt exist. I had...
4
1129
by: Jason Kendall | last post by:
Why is it that there doesn't appear to be an easy way to select what overridable method you want to override from the IDE as you could in VS2003? Used to, you could select (Overrides) for your class from the dropdown at the top of the IDE, on the left, and then pick from a list of overrides on the right. I've not done much in VS2005 yet,...
6
17075
by: murgan | last post by:
Hi people, i am new to this group,this is my first query, friends i want to know the difference between "function pointer" and "pointer to a function" in c lang, so friends please send the answers as early as possible, thanking u all vijay
3
2252
by: jbeteta | last post by:
Hello, I have a problem declaring variables. I need to create an object oRpte as ReportClass on WebForm1.aspx and be able to use its value on WebForm2.aspx. For declaring the property oRpte() on WebForm1.aspx, I use "Public Property" and I declare variable _oRpte as Friend Shared. That's my problem. If I don't declare _oRpte as Friend...
1
1422
by: =?Utf-8?B?QnJldHRWUA==?= | last post by:
I have a child-class that inherits from a base class that implements an Interface. The child class overrides a SUB from the base class that implements a sub from the interface. (The "MapAttributesForImport" is a sub in an interface that is implemented by the base class marked 'overridable'.) This code was fine in VS2003/.net 1.1 and is in...
5
4897
by: peter1234 | last post by:
Could you please confirm if 'Public Type', as defined below, is possible with Access 2003. Symilar example found in a book for Access 2007. Public Type TypeName Type as String Temp as Single Protect As Boolean End Type Public Function FnName() Dim Var1 as TypeName Dim Var2 as TypeName
0
7695
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8119
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.