In this article, I'll write about where I got stuck and struggled when migrating from VB 6.0 to java.
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
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
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