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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

939 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

10 Experts available now in Live!

Get 1:1 Help Now