473,396 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

"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.dll" ( _
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.dll" Alias "htons" ( _
ByRef hostshort As Int16 _
) As Int16

Public Overrides Function htons(ByVal hostshort As Short) As Short
Return htons_API(hostshort)
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 2149

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

Similar topics

6
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)....
4
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...
2
by: Tee | last post by:
what's the differences between "Overrides Sub OnError" and "Sub Page_Error" ?
1
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...
4
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...
6
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...
3
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()...
1
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...
5
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 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.