VB.NET InvokeMember method list - vb.net

I am using the HtmlElement's InvokeMember function and was wondering if there is a nicely formatted list of all the strings that can be passed into that function.
So far I know about these strings that can be passed into InvokeMember:
Click, Focus
Can somebody provide a link to a list of all strings that can be passed into the InvokeMember function or write them down?

MSDN has the list of all the documentation for the classes in the .NET Framework. Here is HtmlElement's documentation listing all of its members:
http://msdn.microsoft.com/en-us/library/system.windows.forms.htmlelement.aspx

Related

how to write a getawaiter for vb.net

I have a program in vb.net (VS 2017) using 4.7 framework, where a function is taking too long to process, interrupting message pumping and causing a timeout error. To solve this I want to run the function asynchronously, using tasks and await. (new to me). I understand that to do that I need to create an asynchronous function (using the async keyword) which uses await to call another asynchronous function which then does the processing. The problem is how to make my own function asynchronous, which internally uses no predefined asynchronous process called by await. To do that it seems I need to have a GetAwaiter defined for my function making it callable using await. Here is where I get stumped. I have searched the web, and looked for books to cover this topic, and I come up short. All the web examples are in C# (which I am not very conversant in), and I can't wrap my head around the C# code examples I have found for creating a GetAwaiter. As an example, from a blog by Stephen Toub there is this:
public static TaskAwaiter GetAwaiter(this DateTimeOffset dateTimeOffset)
{
return (dateTimeOffset – DateTimeOffset.UtcNow).GetAwaiter();
}
to create a GetAwaiter for the DateTimeOffset function. I don't understand the declarative line, specifically the TaskAwaiter GetAwaiter twin and the contents of the parenthesis following the GetAwaiter keyword. I do think that 'this' refers to sender in vb, DateTimeOffset is the name of the function getting the GetAwaiter, and dateTimeOffset is a value being passed, but I don't understand that combination of function names and values inside a paren. How can this line be rewritten in vb? Are there any good, comprehensive books, articles, etc covering the task/await functionality - particularly when you have to create a new asynchronous function, one that is not pre-packaged and included as part of .net, and written including vb examples. I found a very informative youtube presentation by Michael Kennedy, but as in all other examples I've found, it relies on a predefined async function that can be called using await. I need to get my head above water - which way is the surface?

Where in the VB6/VBA project references do Array(), LBound(), and UBound() come from..?

Where in the VB6/VBA project references do Array(), LBound(), and UBound() come from..? When I'm typing in code, they don't appear in the Autocomplete list (ctrl+space), they don't get autocompleted, and they must be typed out completely before the text editor recognizes them. And only when a left-parenthesis is typed will ToolTipText pop up with the command syntax. Also, they do not appear anywhere in Object Explorer.
There's probably a basic concept in play here that I'm not aware of. And it makes me wonder, what other commands/statements/keywords are hidden in the same way..? Is there a list somewhere..? I googled for info but didn't find anything, probably because I don't know what I'm looking for and using the wrong search terms.
I ask these questions because I have the habit of prefixing many VB6 built-in functions like this: VBA.Left(), VBA.Len, VBA.Instr(), and so on. But I can't figure out what reference prefeix to use with Array(), LBound(), and UBound(), or perhaps they're so basic to VB6 that they don't have one.
I do this prefixing because years ago I was working on a large project, and there were functions I was trying to use with the same name in different reference libraries. I was a newbie and it took me a while to figure out, and it was causing tremendous problems since the functions were just NOT working the way I thought they were supposed to. It was then that I developed the prefixing habit after I figured it out. It's just easier that way, and always ensures the expected functions are being used.
The reason that they don't appear as IntelliSense options (and also why they don't appear in the Object Browser) is that they aren't declared in the VBE7.dll typelib for some reason that's beyond me. The Array function is implemented in the .dll as rtcArray. The utility of knowing that is dubious, in that its sole argument is a ParamArray, which means that if you called it directly from VBE7.dll you would need to create an array to have it feed you back the same array... This partially explains why it isn't on the typelib - a COM call would need to do the same thing, and the marshaling would basically be doing the same thing as what you'd expect the function to return.
LBound and UBound don't even appear as functions in the export table, so my guess is that they are handled more like "keywords" than first class functions internally. This makes some sense, in that it's fairly trivial to check the bounds of a SAFEARRAY if you have a pointer to the automation struct (you just index into the rgsabound array at the end of it and read the cElements and lLbound from it. Again a guess, but I'd assume that this allows for flexibility in letting LBound and UBound function with both fixed length and variable length arrays. In the fixed case, the array is basically managed as a block of memory with an indexer (more like a VT_CARRAY than a VT_SAFEARRAY). I'd imagine that handling this internally was easier or more convenient than providing first-class functions.
You won't find Debug in the Object Browser either, nor its methods Assert and Print.
You won't find Statements that are used like methods, like Open, Close, Get and Put, which is why you don't get any Intellisense when you use those statements, and the syntax must be memorized.
You will find Load and Unload as members of VBA.Global, but it's not clear what they belong to otherwise, and their arguments are late-bound Objects. The VBA documentation states that Load and Unload are Statements, even though the Object Browser shows them as Methods.
Keep in mind that you can move the order of references and it will make a difference. Try moving VBA to the top or near the top of your list of references. I believe that if something else also defines a BASIC keyword, it steals it, in a sense. I once had Right disappear and because I was not aware of the order of references, had to change all references of Right to VBA.Right. It's possibly the same with the ubound, lbound, or array.

vb pass name of function using intellisense

I'm tying to implement a novel way of overriding functions based on which DLLs I have loaded. In this model, I have a list of class instances from First = Highest Priority to Last = Lowest priority.
Any of those classes may implement a Hook function or callback. I'm currently at the stage where I can pass a string to a function, and then call it - my library convention looks like this:
Dim hookclasses as HooksList
Dim callable as Object
hookclasses.Add(new ClassA)
hookclasses.Add(new ClassB)
'... etc.
if hookclasses.Has("MyHookFunction", callable) then
callable.MyHookFunction()
end if
This all works, but I'd like to reduce typos by leveraging Intellisense. I've already thought of popping the strings into a class containing constant strings, so I'm after something better than that.
Ideally I'd like to have a fallback class that implements all of the hook functions (even if it simply returns), and if the language supported it, I'd like to do the following:
if hookclasses.Has(NameOf(FallbackClass.MyHookFunction), callable) then ...
Clearly there is no 'NameOf' operator, and I don't know how to write a NameOf function.
Is this possible?
Thanks.
Check this article nameOf (C# and Visual Basic reference)
https://msdn.microsoft.com/en-us/library/dn986596.aspx
It does exactly what you want. And before that String Litterals were almost the only option.
Edit :
Question was : "Clearly there is no 'NameOf' operator, and I don't know how to write a NameOf function."
If I understand your problem right, you have a list of classes that you fetched from dynamically loaded DLL, point is you don't know if a class implements all of the hooks or only a few.
If you use an interface, like IHookable and put all the hook functions in there, it means all the DLL have to implement all the hook functions, which is not what you want.
And (if I understand it properly) if the first class in list does not implement the hook, you check the second one and so on. So with an interface you wouldn't know if the hook is implemented or not.

Where can I find the descriptin of LibreOffice API for BASIC

I wanted to create a few macros for LibreOffice using BASIC. However I cannot find the API description. It is absent in help as well as in interet. When I try to google it I get masses of examples in C++, Java, Python, but not a single www with BASIC.
For example where from can I get the hierarchy of objects and their methods?
LibreOffice Basic uses essentially the same API as PyUNO and Java. That is, they all use the UNO API. To get started, the OpenOffice development guide helpfully describes the two main ways to step into the object hierarchy, the Global variables ThisComponent and, less commonly, StarDesktop. There also is a specialty variant in LO Base, ThisDatabaseDocument. To get the properties and methods of these objects, execute MsgBox oObject.DBG_properties or .DBG_methods. It often is easier to copy the longer lists that are returned by this method into a text editor for searching. You will find that all, or nearly all, of the methods and properties you reveal will be described in the LibreOffice UNO IDL API. The documentation for the API is not that descriptive, but you will be able to fill in some essential details using that resource Every Object has properties that can be reviewed by .DBG_properties.
The key properties for navigating the object hierarchy are .Parent, .Model, .CurrentController and occasionally .Source. The key methods are getByName() and getByIndex(). It also is helpful that events which trigger macros typically return an event object whose source or parent is the object that initiated the macro, for example, a command button. This object can be accessed by referring to it along with the Sub, i.e., Sub SubName (oEventObject As Variant)....

How do I use dynamic objects with asp.net?

I have a dynamic object built inside IronPython and I would like to build controls on my asp.net page dynamically based on what types of objects are nested inside my dynamic object:
dynamic variousComplexObjects = IronPythonApp.GetControls();
repeater.DataSource = variousComplexObjects;
repeater.DataBind();
Can someone write me a quick example of what to do next? I'm sure there is a tutorial out there doing something similar, but I'm having a bit of trouble googling it. Feel free to recommend me the correct keywords or point me in the direction of properly consuming DLR data in an asp.net app.
Thanks!!
Assuming you use .net 4, you can just use dynamic in your databound event.
repeater.ItemDataBound += OnItemDataBound;
protected void OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
dynamic dynObj = (dynamic)e.DataItem;
string text = dynObj.Text; // Etc.
}
I'd probably have a type property or similar to check on - otherwise you're stuck with trying to use GetType() which I'm not certain whether works with IronPython.
Here's a thread entitled "Databind object with 'dynamic' properties". It involves creating customer get and set methods on the type.
It doesn't exactly fit with your scenario of C#'s dynamic and sourcing data from the DLR, but it might help.
Here's another thread entitled "Can I databind to a collection of Dynamic Class". The authored created a dynamic class using Reflection.Emit.
Please comment if any of these solutions fit your case. I'm also interested in the solution, but don't have the tolls to test, at the moment.
Thanks.. I guess nobody is coding in traditional asp.net web forms and dynamic objects. There's probably a way to do it.. but I just switched to MVC instead.