I have a problem while converting the VB6 code to vb.net .Can any one help me to convert the following lines of code?
bin_str = StrConv(imgA, vbUnicode)
bin_str -- > String
imgA -- > Variant type
I believe this the correct way to do this:
bin_str = System.Text.Encoding.Unicode.GetString(imgA)
Related
Im using the FolderBrowserDialog to pick a path.
It will return for ex. this= C:\Mypath1\Mypath2\DOCS
I would like to remove everything but DOCS.
If i use VBA i would use a InStrRev combined with a left. But now in in VB.net and im not sure how to achieve this, im pretty sure there is something better than my old VBA way?
Anyone there that could help, google failed me.
Try this:
IO.Path.GetFileName("C:\Mypath1\Mypath2\DOCS")
Which returns DOCS.
I am not sure what you want to do. But maybe this can help you get the last part of a string
Dim fullPath As String = " C:\Mypath1\Mypath2\DOCS"
Dim Parts As String() = fullPath.Split("\")
Dim lastPart As String = Parts(Parts.Length - 1)
I have a VB.net project in that I need to convert a character into an hex value. According to https://msdn.microsoft.com/de-de/library/963zt96e(v=vs.90).aspx, I tried this (example):
Dim sChar as String = "€"
Dim sNum as Integer = AscW(sChar)
Dim sHex as String = hex(sNum).ToString
When I set a breakpoint after that, I get these values in direct console:
?sNum
8364
?hex(sNum)
"20AC"
Which is correct and works as expected.
But the value calculated in running program is garbage:
?sHex
"20254"
Why do I get different results in running code and direct input console?
And how do I get the expected string value ("20AC")?
okay, found a solution (but no explaination)
sHex = convert.ToString(sNum, 16)
I cannot explain these wrong values, but the code above works for me, just in case that someone else has the same problem.
Is it possible to convert, say, a textbox input to working code?
For example, user types 'if x<10 then y=2 else y=5' into textbox1, it gets used directly as code something like ...
dim x as integer = 5
dim y as integer = 0
include processed textbox1.text
resultbox.text = (y*20).tostring
It's not important why this would be needed - just whether there is any straight-forward method that parses a string to code.
Many thanks.
Maybe this is what you are looking for:
http://www.codeproject.com/Articles/12852/Compile-and-Run-VB-NET-Code-using-the-CodeDom
yes you can do this using the VBCodeProvider class. Although the amount of code required is quite significant:
http://www.codeproject.com/Articles/5472/Compiling-NET-code-on-the-fly
I'm stuck on something simple that I can't figure out why doesn't work now.
I tested the same code before(last Friday) and it works
I just need to get an String with four hexadecimal digits from an integer variable no mather what number between &H0000 and &HFFFF
So I write this simple code
Dim NumHex As Integer = 352
Dim NumHexStr As String = String.Format("{X4:0}", NumHex)
But now I'm getting
"Input string was not in a correct format."
Can you see something wrong on that code?
Thanks.
Your format condition must be String.Format("{0:X4}", value) or Value.ToString("X4") or may be Hex(value).PadLeft(4, "0"c)
I'm working with SQL Server, I'm new to this.
I would like to convert an integer to a string with a specific format like
string sSuffixNoLeadingZero = sSuffixInt.ToString("##0");
This is the code written in C#. I would like to know how to do the conversion to string with ("##0"). Please help me as I'm new to SQL
Thanks a lot.
This removes the leading zeros .
Select CAST(sSuffixInt AS INT) as sSuffixNoLeadingZero