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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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