?
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
Medium Priority
?
208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 

Author Comment

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

Accepted Solution

by:
herreruud earned 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

771 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