There is a great way to call the Fortran intrinsic libraries from Visual Basic, without wrapping them to dynamic libraries. I have the Digital Fortran installed on my computer, so I found out one of the running DLLs which is the dforrt.dll and that contains the Fortran intrinsic libraries (which are used by the Digital compiler). I simply opened the DLL with the Depends program and I found out the name of the functions that are declared in the DLL file. Knowing that the tangent function is declared as DTAN in Fortran, I found out some functions and declared them in a Visual Basic module file like this: Public Declare Function DTAN# Lib "dforrt.dll" Alias "_FXDTAN" (x#) Public Declare Function DTAN5# Lib "dforrt.dll" Alias "_FXIDTAN" (x#) And here is a sample call: Const PI As Double = 3.14159265358979 'the tangent of PI/4 will return 1.0 Debug.Print DTAN(PI / 4) Of course the tangent function is an intrinsic one in Visual Basic. H...
It seems that are not any CopyTo and Sort functions in the Dictionary class that resides in the Systems.Collection.Generic namespace. The OrderBy extension method used by Linq is not very practical to me, because it does not return a dictionary object. Here is my extension method CopyTo, applicable to generic Dictionary objects, allowing to define a part of the dictionary: public static void CopyTo<T, V>(this Dictionary<T, V> source, Dictionary<T, V> target) { if (target == null) target = new Dictionary<T, V>(); foreach (KeyValuePair<T, V> entry in source) target.Add(entry.Key, entry.Value); } public static void CopyTo<T, V>(this Dictionary<T, V> source, Dictionary<T, V> target, int start) { if (target == null) target = new Dictionary<T, V>(); int iEntry = 0; foreach (KeyValuePair<T, V> entry in source) { if (iEntry++ >= start) target.Add(entry.Key, entry.Value); } } public static void CopyTo<T, V>(this Dicti...
I really needed a simple class to associate a file extension to my applications. That's why I created this simple static class that can associate (programmatically) an extension to my application: public static class FileAssociator { //[System.Security.Permissions.RegistryPermission(System.Security.Permissions.SecurityAction.Assert, Unrestricted = true)] public static void AssociateExtension(string extension, string applicationPath, string identifier, string description, string icon) { RegistryKey CR = Registry.ClassesRoot; //CreateRegistryKey HKEY_CLASSES_ROOT\Extension RegistryKey extensionKey = CR.CreateSubKey(extension); //SetRegistryValue of HKEY_CLASSES_ROOT\Extension, use default value, value= Identifier extensionKey.SetValue("", identifier, RegistryValueKind.String); extensionKey.Close(); //CreateRegistryKey HKEY_CLASSES_ROOT\Identifier RegistryKey identifierKey = CR.CreateSubKey...
Comments