Precautions when migrating from VB6.0 to JAVA

Introduction

In this article, I'll write about where I got stuck and struggled when migrating from VB 6.0 to java.

Extract string (Left)

In VB6.0, even if you write a process that takes the 11th character of a variable containing 10 characters, no error will occur. (In the case of the process of acquiring the 0th to 11th characters, the 0th to 10th characters can be acquired.) Therefore, if you write according to the process of migrating to java, there is a possibility that a character count check error (StringIndexOutOfBoundsException) will occur. Therefore, you can avoid the error by checking the number of characters before extracting the character string.

VB source

'Contains abc.
test = Left("abc", 4)

java source


test = "abc";

if (test.length() >= 4) {
  //If there are 4 or more characters, enter up to 4 characters in test2
  test2 = test.substring(0, 4);
} else {
  //If it is less than 4 characters, enter it as it is
  test2 = test;
}

LenB LenB calculates the half-width character of the specified character string as 1 byte and the full-width character as 2 bytes, and returns the total number of bytes. The same implementation as LenB can be done by changing the character string to "Shift_JIS" code and taking the total number of bytes to correspond to the above in java.

About the number of bytes of the character code Link to another site

Points to note when reading the source code

When I was using VB6.0, I often declare all the variables to be used in the process at the beginning of the process. Therefore, there may be variables that are not actually used even if they are declared, or they may be used secretly in the back. (Maybe it's just the case I entered ...) Also, there are some VB6.0 controls and current VB.NET controls that work the same but have different names.

Differences in VB6.0 and VB.NET control names Link to another site

Finally

When you read the source code before migration, you often wonder why you put in such useless processing and why the old method is gone now, but that processing and method When I looked up why I had to use it a long time ago, it seems that I was touched by the history of programmers. It's fun, so if you get a little tired from the transition, you may want to look it up for a change.

Recommended Posts

Precautions when migrating from VB6.0 to JAVA
How to write and notes when migrating from VB to JAVA
ClassCastException occurs when migrating from Java7 to Java8 ~ Generics and overload ~
Changes when migrating from Spring Boot 1.5 to Spring Boot 2.0
Changes when migrating from Spring Boot 2.0 to Spring Boot 2.2
What I thought about when I started migrating from Java to Kotlin
From Java to Ruby !!
Precautions when converting from decimal number to binary number
Migration from Cobol to JAVA
Summary of points I was worried about when migrating from java to kotlin
New features from Java7 to Java8
Migrating from vargrant to docker
Connect from Java to PostgreSQL
From Ineffective Java to Effective Java
[Opens aml] NoClassDefFoundError occurs when migrating from Tomcat to weblogic
Notes on character encoding when migrating from windows to Mac
Java to be involved from today
From Java to VB.NET-Writing Contrast Memo-
Java, interface to start from beginner
Notes on migrating from CircleCI 1.0 to 2.0
The road from JavaScript to Java
[Java] Conversion from array to List
Notes on building Kotlin development environment and migrating from Java to Kotlin
Convert from java UTC time to JST time
Story when moving from Spring Boot 1.5 to 2.1
Connect from Java to MySQL using Eclipse
From installing Eclipse to executing Java (PHP)
Post to Slack from Play Framework 2.8 (Java)
Java: How to send values from Servlet to Servlet
[Java] Flow from source code to execution
Introduction to monitoring from Java Touching Prometheus
Memo for migration from java to kotlin
Type conversion from java BigDecimal type to String type
Troubleshooting when raising Mastodon from v3.0.x to v3.1.x
Update JAVA to the latest version to 1.8.0_144 (when downloading from the web and updating)
[Java] Tips and error issues when converting from double to Big Decimal
Summary of good points and precautions when converting Java Android application to Kotlin
[Java] From two Lists to one array list
Upsert from Java SDK to Azure Cosmos DB
Run R from Java I want to run rJava
Things to be aware of when writing Java
[Promotion of Ruby comprehension (1)] When switching from Java to Ruby, first understand the difference.
To become a VB.net programmer from a Java shop
Migrate from Java to Server Side Kotlin + Spring-boot
Summary of moss when updating from JMockit 1.4 to 1.30
How to get Class from Element in Java
[Java] Introduction to Java
[Java] How to switch from open jdk to oracle jdk
What I did when I converted java to Kotlin
I want to write quickly from java to sqlite
Introduction to java
Minecraft BE server development from PHP to Java
Select * from Java SDK to Azure Cosmos DB
When inserting from Java to MySQL, get Auto_Increment_ID (automatic numbering value) as the return value
Docker for Windows: MySQL container does not start when migrating from Hyper-v to WSL2
Launch Docker from Java to convert Office documents to PDF
Convert Java enum enums and JSON to and from Jackson
[Java] I want to calculate the difference from the date
How to jump from Eclipse Java to a SQL file
Behavior when calling Java variadic methods from Scala / Kotlin / Java
[Java] How to extract the file name from the path