Solved

Is it possible to call a Java-function from VB6 and get the returned data from the function call?

Posted on 2006-10-19
6
202 Views
Last Modified: 2010-04-30
Is it possible to call a Java-function from VB6 and get the returned data from the function call?
0
Comment
Question by:expertfan
  • 2
6 Comments
 

Author Comment

by:expertfan
ID: 17764175
if yes, please post a sample program.
0
 
LVL 3

Accepted Solution

by:
herreruud earned 500 total points
ID: 17764223
Hi,

I did a seach to see if Java is COM-capable, and apparently it is.
What you need to do is expose your java functon in a COM-object and reference it in VB6.
I don't really know Java, but I found this link describing how to register a java class as a COM server: http://www.rgagnon.com/javadetails/java-0044.html

(I'll be using the Java-class from the link in this example)

When you have registered the COM-object according to the instructions you can add a reference to it in VB6:

1. Open VB6
2. Start a new standard windows exe project
3. Choose "Project"->"References" on the menu.
4. Add your Java Object.
5. Drop a CommandButton onto your form.
6. Double-click your form; you should be presented with this:

Private Sub Command1_Click()

End Sub

7. Change it to this:

Private Sub Command1_Click()
    Dim oJava As JavaCom.JavaSays
    Set oJava = New JavaCom.JavaSays
   
    MsgBox oJava.Hello
    MsgBox oJava.Say("String passed through Java object")

End Sub

 
0
 
LVL 3

Expert Comment

by:herreruud
ID: 18048065
I believe I provided the correct answer, but the author never responded...

/Christian
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now