Shoutbox

JScript To VB6 - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: JScript To VB6 (/showthread.php?tid=64917)

JScript To VB6 by ecion on 08-14-2006 at 07:34 PM

Hey,
i was wondering if anyone knows how (if its even possible) to send data from JScript directly to a VB6 application? Other wise I guess i'll have to write to a text file from JScript and use VB6 to read it?
Many Thanks


RE: JScript To VB6 by RaceProUK on 08-14-2006 at 08:20 PM

Both JScript and VB6 are Automation clients, so passing data between them is really stupidly ridiculously easy. Just create the ActiveX object in JScript, and call methods and properties like you would any other JScript object.


RE: JScript To VB6 by matty on 08-14-2006 at 08:50 PM

[Resolved] Talking to VB.


RE: JScript To VB6 by ecion on 08-15-2006 at 10:14 AM

Hmm. Thanks for that. However i am still having trouble sending data from JScript to VB.
Going by Matty's example. I have a project1.dll with a string fuction called ContactID. In this function I set the string varible to 'hello' (for test purposes). Then I have this in my Plus! Script:

    var MyActiveXObject = new ActiveXObject('Project1.Class1');
    MyActiveXObject.ContactID = Messenger.MyName;
    Debug.Trace(MyActiveXObject.ContactID());

But keep getting errors on the middle line, where i'm trying to assign a value to the string i made in the dll. If i comment out the line, then the rest works, and the backup varible 'hello' is displayed as it should. Any ideas what I'm doing wrong?


RE: JScript To VB6 by RaceProUK on 08-15-2006 at 10:30 AM

Since ContactID is a function, MyActiveXObject.ContactID = Messenger.MyName; is meaningless. Make ContactID a property, then you can assign like that. And also remove the () from Debug.Trace(MyActiveXObject.ContactID());


RE: JScript To VB6 by ecion on 08-15-2006 at 10:40 AM

but its both a function and a property? As I said, I was going by the example given in the thread Matty Linked to. So my DLL has the following:

Public Function ContactID() As String
ContactID = "Hello"
End Function

So i should be able to assign values to contactID right? :S


RE: JScript To VB6 by CookieRevised on 08-15-2006 at 10:51 AM

quote:
Originally posted by ecion
but its both a function and a property? As I said, I was going by the example given in the thread Matty Linked to. So my DLL has the following:

Public Function ContactID() As String
ContactID = "Hello"
End Function

So i should be able to assign values to contactID right? :S
No.

ContactID(), in your VB example, is just a function without any input parameters. It can only output a string, nothing more; it isn't a property either. So all you can do in JScript with it is calling the function, you can't pass anything to it.



What you probably want is making a function which also accepts a parameter:

VB (in the public class)
code:
Public Function ContactID(inputstring As String) As String
        ContactID = "Hello " & inputstring
End Function
JScript
code:
var MyActiveXObject = new ActiveXObject('Project1.Class1');
Debug.Trace(MyActiveXObject.ContactID(Messenger.MyName));

RE: JScript To VB6 by ecion on 08-15-2006 at 12:07 PM

cheers for that CookieRevised, works now. :)

however, i've came across another problem, since starting my main project (before was obviously just to learn how to do the basics).
Now im trying to send the contacts email address to the dll when they sign in, and im using this to do it:

function OnEvent_ContactSignin(Email){
    var MyActiveXObject = new ActiveXObject('Project1.Class1');
    var Contacts = Messenger.MyContacts
    var Contact = Contacts.GetContact(Email)
    MyActiveXObject.main1(Contact.Email)
}

It works. However, one slightly odd problem is that when the contact really signs in, i get the info sent to my dll, and the contact is shown online in the contact list. good.
But while trying to do this quickly for testing, i was just blocking/unblocking, to mimic a sign-in, and although i got the info to my dll saying the contact came online - the contact is not shown online in the contact list. :S  i guess thats some sort of bug in wlm, or plus? :S


RE: JScript To VB6 by ShawnZ on 08-15-2006 at 05:35 PM

quote:
Originally posted by ecion
var Contacts = Messenger.MyContacts
var Contact = Contacts.GetContact(Email)
MyActiveXObject.main1(Contact.Email)

you realize that you're using two lines of code to get the contact object from the email, just so you can get the email from the contact object, right?