How to write and notes when migrating from VB to JAVA


When migrating from VB to JAVA, I will write the processing of VB that I investigated and notes.

if statement

It's basically the same as java. Ternary operator Uses IIf. (IIf (conditional expression, true, false))

'Variable declaration'
Dim test As Integer

test = 10

If test = 10 then

End If

test2 = IIf(test = 10, "true", "false") 

java source

if (test == 10) {

test2 = test ? "true" : "false";

for statement

The value before TO is the initial value, the value after TO is the end value (if "5" is specified in TO, it is repeated until it becomes "5" or later), and step is the increase value. step is optional, and if there is no step, the initial value is incremented by 1 each time it is looped.

** If step contains a negative number, it loops until the initial value falls below the end value. ** **

VB source

'① Addition'
For test = 2 TO 6 step 2
  'Add test values by 2'

'② Subtraction'
For test = 10 TO 6 step -2
  'Subtract the value of test by 2'

java source

//① Addition
for (int test = 2; test <= 6; i+=2) {

//② Subtraction
for (int test = 2; test >= 10; i-=2) {

format When you replace the VB format with java, you can basically replace it as it is by using DecimalFormat. ** However, "/" cannot be used in DecimalFormat, so SimpleDateFormat is used. ** **

VB source

'10000 to 10,Display at 000'
format(10000, "###,###")

'20180426 2018/04/Show at 26'
format(20180426, "####/##/##")

java source

DecimalFormat df = new DecimalFormat("###,###");

//10000 to 10,Display at 000

SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");

SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd");

Date date = sdf.parse("20180426");

//20180426 2018/04/Show at 26

new line

For VB, use "vbCrLf" if you want to start a new line.


The basic idea is the same for VB and JAVA. However, since the VB side has abundant functions, when you replace the source code with JAVA as it is, you may have to write a new process on the java side, so be careful.

Recommended Posts

How to write and notes when migrating from VB to JAVA
Precautions when migrating from VB6.0 to JAVA
ClassCastException occurs when migrating from Java7 to Java8 ~ Generics and overload ~
[Java] How to output and write files!
Notes on building Kotlin development environment and migrating from Java to Kotlin
How to write java comments
How to write Scala from the perspective of Java
[Java] Types of comments and how to write them
Studying Java # 6 (How to write blocks)
How to write Java variable declaration
Notes on migrating from CircleCI 1.0 to 2.0
Notes on character encoding when migrating from windows to Mac
Basics of Java development ~ How to write programs (variables and types) ~
[Java] How to write when passing two or more arguments to super
[Java] How to convert from String to Path type and get the path
What I thought about when I started migrating from Java to Kotlin
[Introduction to Java] How to write a Java program
Changes when migrating from Spring Boot 1.5 to Spring Boot 2.0
Java: How to send values from Servlet to Servlet
Changes when migrating from Spring Boot 2.0 to Spring Boot 2.2
How to write and explain Dockerfile, docker-compose
Update JAVA to the latest version to 1.8.0_144 (when downloading from the web and updating)
Java beginner escape boot camp Part 1 Java class structure and how to write
[Java] Tips and error issues when converting from double to Big Decimal
JDBC promises and examples of how to write
[Java] How to use FileReader class and BufferedReader class
[Rails] How to write when making a subquery
Java Development Basics ~ How to Write Programs * Exercise 1 ~
[Java] How to get and output standard input
How to get Class from Element in Java
[Java] How to switch from open jdk to oracle jdk
How to get and study java SE8 Gold
I want to write quickly from java to sqlite
[Java] Memo on how to write the source
How to write Java String # getBytes in Kotlin?
How to access Java Private methods and fields
Notes on how to write comments in English
[Java] How to use Calendar class and Date class
Basics of Java development ~ How to write a program (flow and conditional branching) ~
Summary of points I was worried about when migrating from java to kotlin
Changes from Java 8 to Java 11
Sum from Java_1 to 100
How to write Rails
How to write Mockito
From Java to Ruby !!
How to write migrationfile
Convert Java enum enums and JSON to and from Jackson
How to jump from Eclipse Java to a SQL file
java: How to write a generic type list [Note]
[Java] How to extract the file name from the path
Java memory management and how to read GC Viewer
How to change from Oracle Java 8 to Adopt Open JDK 9
How to remove Ubuntu when dual booting Windows and Ubuntu
[Java] How to erase a specific character from a character string
How to convert A to a and a to A using AND and OR in Java
How to write modern Java. Immutable Java, consider Null safety.
Notes on how to use regular expressions in Java
How to automatically generate ER diagram when migrating with Rails6
How to test including images when using ActiveStorage and Faker
[Java] How to use Map
Let's write how to make API with SpringBoot + Docker from 0