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
206 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 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…

737 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