Is V() a utility function in Visual Basic? - vba

I'm trying to reverse engineer a calculator made with visual basic. The original author has this function called on a lot of variables that looks like:
V(Offset)
V(CPX)
V(CAng)
I can't find this anywhere in any of the functions that he wrote. But I also don't think this is a utility function in visual basic. Does anyone know what this means?
My best guess is that this is converting the units of the numbers it is called on to a format that is compatible with other numbers.

As mentioned by GSerg above, V is not a utility function.

Related

Visual Basic lack of parenthesis for functions identification

Any way to have any sort of identification for the lack of parenthesis for functions with no parameters at VB?
I have found this answer, but since it is 9 year old, i hope a solution exists now.
I am using Visual studio 2017. I have strict mode on. I have checked format settings available for Visual Studio and found no relative option. I have checked project settings as well.
Edit:
I have noticed that when i type a new function name that it does add parenthesis, could this be triggered somehow?
You are not going to find what you need built into the compiler or project settings, because the optional parenthesis are build into the VB.Net language specification and the compiler will compile according to that specification. Now one thing you might want to consider is running your code through a VB.Net to C# Converter, then running that converted code through a C# to VB.Net converter. For example, consider this VB.Net code:
Sub Main
Foo
End Main
If you run this through Telerik's code converter, it produces this C# code:
public void Main()
{
Foo();
}
Now if you take that C# code and convert it back into VB.Net using Telerik's code Converter, it produces this Vb.Net code:
Public Sub Main()
Foo()
End Sub
Notice how it added the parenthesis to the Foo method. This technique might work for you, if your code isn't too complex.

Using StatePrinter from VB rather than C# to implement ToString

I'm trying to follow the promising suggestion posted here to try StatePrinter as a shortcut to rolling my own ToString methods. I agree with the OP that it is a shame that VS still can't generate this method for me.
I've got a fairly large project, in VS2015 (Community Edition), with both VB and C# code. I added the current stable version of StatePrinter using NuGet.
I can make the example code from the SO answer work fine in my C# code but when I do what I think is the equivalent in my VB code:
Private Shared sp As StatePrinter.Stateprinter = New StatePrinter.Stateprinter
Public Overrides Function ToString() As String
Return sp.PrintObject(Me)
End Function
I just get the compiler error
'Stateprinter' is ambiguous in the namespace 'StatePrinter'
There IS another constructor, StatePrinter (note difference in capitalization only) which is deprecated and, in any case, generates the same error message.
I'm led to the unfortunate conclusions that
VB in VS2015 is acting as if it is case insensitive. Can that be true?
No one else is using StatePrinter from VB.
Can anyone provide any suggestions on how to use StatePrinter from VB? I'm willing to believe I'm making some rather brain-dead mistake in converting the C# example to VB.
It is near impossible to use this directly in VB and get around the ambiguous name issue. You could write a class library wrapper in C# that doesn't expose this mismatch (that is, it has an internal StatePrinter object and exposes constructors that are PascalCased the same.
Another option would be to use reflection in the VB project to get around the case insensitivity.
You could also create a GitHub issue. Or, be a contributor to the project and create a suggested fix for it. :)
As soon as I got done writing #1 in the question above, I was able to figure out how to search for the answer to that bit.
Yes, VB is case insensitive, at least, as far as it needs to be in this case:
See the rather nice writeup here:
https://stackoverflow.com/a/2301980/165164
So, we're left with the rather plaintive: is no one else using StatePrinter from VB?

Identifying Late binding in VB.NET

I have an application which had been migrated to VB to VB.NET. Now in few places in VB there were code written for using Trim operation on a non-string Datatype. The code runs well in VB but the same produce error on migrated code in VB.NET.Following is the code snippet
dr["N0"].Trim() ----where "NO" is an integer or any non-string DataType
I want to identify these places in my migrated VB.NET code base. How I can do that without minimal effort? Any efficient idea or technique?
Just gate these with TypeOf http://msdn.microsoft.com/en-us/library/0ec5kw18.aspx, you could even use a Debug.Alert(); so as you're going through the program you get alerted (in debug mode).

Is there a library out there to analyze VB.Net code complexity from my C# code?

Given VB.Net code in a string, is there a library (or a command line tool) out there that could calculate Cyclomatic Complextiy and LOC?
This has to be done within my C# code.
Thanks.
There is Refactor!, which does supply some extensibility and also supplys the mesurements (And an extesibility point)
Besides that, there is also NDepend, which allows you to query your code for such infos:
http://www.ndepend.com/Features.aspx

Visual Studio VB pretty listing settings

Does anyone know how to stop Visual Studio VB.NET editor from changing my beautiful scientific notation numbers into hideous decimal notation?
It seems that this is part of "Pretty Listing" (single checkbox in the options). I'd like to keep the other features of pretty listing, I just don't want to have to stare at 0.0000000000000001 when I could be looking at 1e-16
I don't think there's a way to do it. You could rely on the implicit CDbl() conversion in this situation:
Dim myPrettyNumber As Double = "1E-16"
Or if you just want to be able to read it more easily, add a comment:
Dim myUglyNumber As Double = 0.0000000000000001 ' 1E-16
You may turn pretty listing back on after defining your constants.
Visual Basic won't obfuscate numbers that have already been defined so long as you don't modify the lines that they're on. If you accidentally do modify a line being forced to scientific notation Visual basic will only convert that line to use fixed notation.
Obviously this works best for the declaration of constants or formula's that won't change very often. It is less viable otherwise.
There is an option in VB to turn off "pretty listing":
http://msdn.microsoft.com/en-us/library/vstudio/y0y5th94.aspx