When migrating from VB to JAVA, I will write the processing of VB that I investigated and notes.
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";
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'
Next
'② Subtraction'
For test = 10 TO 6 step -2
'Subtract the value of test by 2'
Next
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
df.format(10000);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd");
Date date = sdf.parse("20180426");
//20180426 2018/04/Show at 26
sdf2.format(date)
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