Home > Software engineering >  VB InStr and len function use question
VB InStr and len function use question

Time:09-17

A is a string "[7 7 July 7 7-32000]..." a total of 34 7 and a - 32000, Numbers separated by a space between
B=InStr (a, "[") c=InStr (a,"] ") d=len (a)
Why is equal to 77 c. A=79 mystery, which to solve thank you very much,

CodePudding user response:

I test here, completely normal!
See the screenshot,


In addition, Instr () function, it seems that everyone didn't write according to the "standard usage",
For example, b=InStr (a, "[")
Should be spelled correctly, b=InStr (1, a, "[")!
Although its parameters are "default", but it is the first parameter is the "starting looking for position,"
Even by VB6 syntax, should also be written as b=InStr (, a, "[")!!!!!!
May IDE according to parameter type, go to "match" the related parameters, so the first comma provinces, also didn't give you an error,
My own code, is never omit the first parameter in the screenshot below, just to test according to the building code format, just saved,

You say a="79", "d=79" should be!
However, my test results, c and d are 77,

CodePudding user response:

I just don't understand why C is 77? 35 digital plus in the middle of the space, and two brackets, why is 77 characters?

CodePudding user response:

Number 35, 34 "7" chief is 34 bytes, - 32000 is 6 bytes, a total of 40 bytes, plus 35 Spaces and two brackets, why not 77 bytes?

Instr format is compatible with omitting the first parameter, for example Microsoft also is such, only when the initial byte is not equal to 1, only need 3 parameters format,

CodePudding user response:

] in front of a total of:
34 7 + + 34 Spaces behind the negative number 6 characters + negative bottom 1 Spaces + front bracket 1 character
=34 + 34 + 6 + 1 + 1=76
That], of course, is the 77th anymore
There is nothing wrong with c=77

CodePudding user response:

I thought the building Lord says is a "d=79", a mystery...
Get along while, incredibly say is can't understand c=77,

C=77 is obvious, but I don't understand "d=79" of the building Lord come from!

CodePudding user response:

Suddenly thought of a problem: not visible characters

Don't know what is the value of a string of the building Lord, may it at the end of the vbCrLf,
You seem to be], the end of the actual has two characters: carriage returns, line feeds,
Such as: are you from Excel workbook Ctrl + C, a cell or the start of a line from "notepad" drag the mouse down to the start of the next line selected text, then Ctrl + C,
And then into the TextBox of VB6 Ctrl + V, again later... Your code. Take the Text that will appear this kind of thing,

CodePudding user response:

D=79, nine times out of ten is right behind a carriage returns, VBCRLF

CodePudding user response:

The invisible characters into the corresponding visible form, are the basic skills of the programmer,

CodePudding user response:

refer to the eighth floor zhao4zhong1 response:
turn invisible characters into corresponding visible form, are the basic skills of programmers,

The key is to look at the need to how to deal with, and specific requirements,

"Into a visible" in most case, it is not this kind of demand, are part of the intercept need for processing,

CodePudding user response:

Programmers need basic skills is actually only recognize and deal with the data, the need to deal with the rest of the let it go, to tolerance, to allow junk to come in, need to be able to find from the trash can eat eat, and even into the trash can eat...
  • Related