Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

who can help me translate the vb6 code to java

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have the vb6 code as follows:



now I want to translate above code to the java code ,
but I donot know how to do it,
anyone can help me?
thanks a lot
 
Marshal
Posts: 76479
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I think the first thing to do with that code is to explain exactly what it does.
 
lowercase baba
Posts: 13074
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you know what this code does?
that is step 1. You need to be able to explain it as if you were talking to a child. If you can't do that, there's no reason to talk about java yet.
 
jacky bushy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the method used to type conversion , convert the bytes(size is 16) to long
 
jacky bushy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

the above code is used to convert the hexadecimal to the long,

I donot know why use "&H" & in vb6 code,
and how to translate it into the java code
 
Campbell Ritchie
Marshal
Posts: 76479
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is because you are still looking at the code and wondering how it does it, not what it does. Please start by explaining what the input is and what the output is.
 
Bartender
Posts: 5074
189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

jacky bushy wrote:
the above code is used to convert the hexadecimal to the long,

I donot know why use "&H" & in vb6 code,
and how to translate it into the java code


"&H" & strHex

just puts "&H" in front of the string strHex. '&' concatenates
two strings in VB. Prepending strHex with "&H" is necessary
to make VB interprete the string as a hexadecimal string.

Just enter "&H" and "VB" in your Google search bar, and you can read all
about it.

Now, for the Java version:
have a look at the String class API, you will see a very handy constructor
that takes a byte array as input.
Next, have a look at the Long class API, section 'parsexxx'. You will
find a convenient method there.

Give it a try.
 
Check your pockets for water buffalo. You might need to use this tiny ad until locate a water buffalo:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic