What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » JScript To VB6

JScript To VB6
Author: Message:
ecion
Junior Member
**

Avatar

Posts: 25
Reputation: -1
37 / Male / –
Joined: Jul 2004
O.P. JScript To VB6
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
[Image: ecion_megane_sig2.jpg]
08-14-2006 07:34 PM
Profile PM Web Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: JScript To VB6
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.

This post was edited on 08-14-2006 at 08:20 PM by RaceProUK.
[Image: spartaafk.png]
08-14-2006 08:20 PM
Profile PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: JScript To VB6
[Resolved] Talking to VB.
08-14-2006 08:50 PM
Profile E-Mail PM Find Quote Report
ecion
Junior Member
**

Avatar

Posts: 25
Reputation: -1
37 / Male / –
Joined: Jul 2004
O.P. RE: JScript To VB6
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?
[Image: ecion_megane_sig2.jpg]
08-15-2006 10:14 AM
Profile PM Web Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: JScript To VB6
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());

This post was edited on 08-15-2006 at 10:31 AM by RaceProUK.
[Image: spartaafk.png]
08-15-2006 10:30 AM
Profile PM Web Find Quote Report
ecion
Junior Member
**

Avatar

Posts: 25
Reputation: -1
37 / Male / –
Joined: Jul 2004
O.P. RE: JScript To VB6
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
[Image: ecion_megane_sig2.jpg]
08-15-2006 10:40 AM
Profile PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: JScript To VB6
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));

This post was edited on 08-15-2006 at 10:58 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
08-15-2006 10:51 AM
Profile PM Find Quote Report
ecion
Junior Member
**

Avatar

Posts: 25
Reputation: -1
37 / Male / –
Joined: Jul 2004
O.P. RE: JScript To VB6
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
[Image: ecion_megane_sig2.jpg]
08-15-2006 12:07 PM
Profile PM Web Find Quote Report
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
32 / Male / Flag
Joined: Jan 2003
RE: JScript To VB6
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?
Spoiler:
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
08-15-2006 05:35 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On