Problem with Persian_CI_AI collation And 'ك' character - collation

I installed sql server 2008 enterprise and created a sample database whit Persian_CI_AI Collation. then from a visual studio 2010 windows application i insert the word "اسكندر" whith two type of 'ك'(arabic & Persian) but in the search time result show me just one 'اسكندر' . Please Help me

you can this procedure in vb.net for your problem
''' <summary>
''' این روال در برطرف کردن مشکل جستجوی حروف عربی کاربرد دارد
''' مقدار خروجی حرف ی فارسی را با یاء عربی جایگزین میکند
''' </summary>
''' <param name="strInputValue"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Function Resolve_Arabic_Font_2(ByVal strInputValue As String) As String
Dim strOutPut As String = ""
If strInputValue.Trim <> "" Then
strOutPut = Replace(strInputValue, "ی", Chr(237))
Else
strOutPut = strInputValue
End If
'---------------
Return strOutPut
End Function

Read the text and then change ك with ک
also change search text with this method.

Related

Multiplatform Windows and MAC computer indentify

is there any multiplatform method to identify user account, system or entire computer? Something like:
CreateObject("Scripting.FileSystemObject").GetDrive("C:\").SerialNumber
It may use some combinations of username and other variables to build (quite) unique ID text/number. Maybe should I use Environ? But where can I find complete list multiplatform Environ working variables? It may use OS identification also.
EDIT some starting code to clarify my question
Sub GenerateID()
#If Mac Then
'------- Mac ---------------
MsgBox MacIdNumber
#Else
'------- Windows -----------
MsgBox WindowsIdNumber
#End If
End Sub
Function MacIdNumber() As Long
Dim str1, str2, str3 ' str4, str5...
str1 = VBA.Environ$("USER")
str2 = Application.Version
str3 = Application.OperatingSystem
' and here I am looking for another ideas
' str4 = ...???
MacIdNumber = CreateUniqueId(str1, str2, str3)
End Function
Function WindowsIdNumber() As Long
Dim str1, str2, str3, str4 ', str5...
str1 = CreateObject("Scripting.FileSystemObject").GetDrive("C:\").SerialNumber
str2 = VBA.Environ$("USERNAME")
str3 = Application.Version
str4 = Application.OperatingSystem
' and here I am looking for another ideas
' str5 = ...???
' but maybe for Windows disc SerialNumber is enough
WindowsIdNumber = CreateUniqueId(str1, str2, str3, str4)
End Function
Function CreateUniqueId(ParamArray str() As Variant) As Long
' here I'll make checksum
' some calculations...
End Function
I am trying to get as unique ID strings as possible (but I know it probably won't be 100% unique).
It must work in reliable way for MAC 2016 and higher and Windows versions of course. So If you give an idea with apple script- I must be sure that no endless loop/ error occurs.
I am Windows user and I am not able to test it on MAC right now.
Is this what you are trying? tested it on both Excel 2016 (Mac/Windows)
Option Explicit
Sub GenerateID()
#If Mac Then
'------- Mac ---------------
MsgBox GetUniqueID("Mac")
#Else
'------- Windows -----------
MsgBox GetUniqueID("Win")
#End If
End Sub
Private Function GetUniqueID(sys As String) As String
Select Case sys
Case "Mac"
'~~> Ref: http://www.rondebruin.nl/mac/mac003.htm
Dim AppleScript As String
AppleScript = "set uuid to do shell script ""system_profiler SPHardwareDataType" & _
" | awk '/Hardware UUID:/ {print $NF}'"""
On Error Resume Next
GetUniqueID = MacScript(AppleScript)
On Error GoTo 0
Case "Win"
GetUniqueID = CreateObject("Scripting.FileSystemObject").GetDrive("C:\").SerialNumber
End Select
End Function
Screenshot
Looks like the answer is "no".
According to https://learn.microsoft.com/en-us/office/vba/api/overview/office-mac
Office 2016 for Mac is sandboxed
Unlike other versions of Office apps that support VBA, Office 2016 for
Mac apps are sandboxed.
Sandboxing restricts the apps from accessing resources outside the app
container. This affects any add-ins or macros that involve file access
or communication across processes. You can minimize the effects of
sandboxing by using the new commands described in the following
section.
What this says to me is that you are going to have to use a different, native, scripting language to get the information you want in to Excel.

Extract file names from a File Explorer search into Excel

This has been bugging me for while as I feel I have few pieces of the puzzle but I cant put them all together
So my goal is to be able to search all .pdfs in a given location for a keyword or phrase within the content of the files, not the filename, and then use the results of the search to populate an excel spreadsheet.
Before we start, I know that this easy to do using the Acrobat Pro API, but my company are not going to pay for licences for everyone so that this one macro will work.
The windows file explorer search accepts advanced query syntax and will search inside the contents of files assuming that the correct ifilters are enabled. E.g. if you have a word document called doc1.docx and the text inside the document reads "blahblahblah", and you search for "blah" doc1.docx will appear as the result.
As far as I know, this cannot be acheived using the FileSystemObject, but if someone could confirm either way that would be really useful?
I have a simple code that opens an explorer window and searches for a string within the contents of all files in the given location. Once the search has completed I have an explorer window with all the files required listed. How do I take this list and populate an excel with the filenames of these files?
dim eSearch As String
eSearch = "explorer " & Chr$(34) & "search-ms://query=System.Generic.String:" & [search term here] & "&crumb=location:" & [Directory Here] & Chr$(34)
Call Shell (eSearch)
Assuming the location is indexed you can access the catalog directly with ADO (add a reference to Microsoft ActiveX Data Objects 2.x):
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
cn.Open "Provider=Search.CollatorDSO;Extended Properties='Application=Windows'"
sql = "SELECT System.ItemNameDisplay, System.ItemPathDisplay FROM SystemIndex WHERE SCOPE='file:C:\look\here' AND System.Kind <> 'folder' AND CONTAINS(System.FileName, '""*.PDF""') AND CONTAINS ('""find this text""')"
rs.Open sql, cn, adOpenForwardOnly, adLockReadOnly
If Not rs.EOF Then
Do While Not rs.EOF
Debug.Print "File: "; rs.Collect(0)
Debug.Print "Path: "; rs.Collect(1)
rs.MoveNext
Loop
End If
Try using the next function, please:
Function GetFilteredFiles(foldPath As String) As Collection
'If using a reference to `Microsoft Internet Controls (ShDocVW.dll)_____________________
'uncomment the next 2 lines and comment the following three (without any reference part)
'Dim ExpWin As SHDocVw.ShellWindows, CurrWin As SHDocVw.InternetExplorer
'Set ExpWin = New SHDocVw.ShellWindows
'_______________________________________________________________________________________
'Without any reference:_____________________________________
Dim ExpWin As Object, CurrWin As Object, objshell As Object
Set objshell = CreateObject("Shell.Application")
Set ExpWin = objshell.Windows
'___________________________________________________________
Dim Result As New Collection, oFolderItems As Object, i As Long
Dim CurrSelFile As String
For Each CurrWin In ExpWin
If Not CurrWin.Document Is Nothing Then
If Not CurrWin.Document.FocusedItem Is Nothing Then
If left(CurrWin.Document.FocusedItem.Path, _
InStrRev(CurrWin.Document.FocusedItem.Path, "\")) = foldPath Then
Set oFolderItems = CurrWin.Document.folder.Items
For i = 0 To oFolderItems.count
On Error Resume Next
If Err.Number <> 0 Then
Err.Clear: On Error GoTo 0
Else
Result.Add oFolderItems.item(CLng(i)).Name
On Error GoTo 0
End If
Next
End If
End If
End If
Next CurrWin
Set GetFilteredFiles = Result
End Function
Like it is, the function works without any reference...
The above function must be called after you executed the search query in your existing code. It can be called in the next (testing) way:
Sub testGetFilteredFiles()
Dim C As Collection, El As Variant
Set C = GetFilteredFiles("C:\Teste VBA Excel\")'use here the folder path you used for searching
For Each El In C
Debug.Print El
Next
End Sub
The above solution iterates between all IExplorer windows and return what is visible there (after filtering) for the folder you initially used to search.
You can manually test it, searching for something in a specific folder and then call the function with that specific folder path as argument ("\" backslash at the end...).
I've forgotten everything I ever knew about VBA, but recently stumbled across an easy way to execute Explorer searches using the Shell.Application COM object. My code is PowerShell, but the COM objects & methods are what's critical. Surely someone here can translate.
This has what I think are several advantages:
The query text is identical to what you wouold type in the Search Bar in Explorer, e.g.'Ext:pdf Content:compressor'
It's easily launched from code and results are easily extracted with code, but SearchResults window is available for visual inspection/review.
With looping & pauses, you can execute a series of searches in the same window.
I think this ability has been sitting there forever, but the MS documentation of the Document object & FilterView method make no mention of how they apply to File Explorer.
I hope others find this useful.
$FolderToSearch = 'c:\Path\To\Folder'
$SearchBoxText = 'ext:pdf Content:compressor'
$Shell = New-Object -ComObject shell.application
### Get handles of currenlty open Explorer Windows
$CurrentWindows = ( $Shell.Windows() | Where FullName -match 'explorer.exe$' ).HWND
$WinCount = $Shell.Windows().Count
$Shell.Open( $FolderToSearch )
Do { Sleep -m 50 } Until ( $Shell.Windows().Count -gt $WinCount )
$WindowToSerch = ( $Shell.Windows() | Where FullName -match 'explorer.exe$' ) | Where { $_.HWND -notIn $CurrentWindows }
$WindowToSearch.Document.FilterView( $SearchBoxText )
Do { Sleep -m 50 } Until ( $WindowToSearch.ReadyState -eq 4 )
### Fully-qualified name:
$FoundFiles = ( $WindowToSearch.Document.Folder.Items() ).Path
### or just the filename:
$FoundFiles = ( $WindowToSearch.Document.Folder.Items() ).Name
### $FoundFIles is an array of strings containing the names.
### The Excel portion I leave to you! :D

Trying to get lotusscript json reader

Through LotusScript I am consuming a webpage that returns json values and I have been unable to find any library out there for lotusscript, other than ls.snapps.JSONReader from openntf. It works, but documentation is limited. I am having trouble reading a nested array in the value list. I was able to get it to work in java using the ibm.common.utils.... library, but was having trouble with mac client and another library (javax.swing.*) so I switched to LotusScript.
I am hoping someone else has experience with the ls.snapps.JSONReader library, or maybe a different idea on how to do this. Here is the sample:
to read it I use
Dim jsonReader As jsonReader
Dim vResults As Variant
Dim vPieces As Variant
Dim sJSON As string
sJson= |{ "colorsArray":[{
"red":"#f00",
"green":"#0f0",
"blue":"#00f",
"cyan":"#0ff",
"magenta":"#f0f",
"yellow":"#ff0",
"black":"#000"
}
]
}|
Set jsonReader = New JsonReader
Set vResults = jsonReader.parse(sJson)
vPieces = vResults.items
I have no trouble when I set a single level object such as:
sJSON = |{"a":"a4255524","a24":true,"ax":"WER!!","b":"Some text"}|
I use the getItemValue method
msgbox vResults.getitemValue("a24")
will return a 'true' value
Has anyone used this JSON parser and can you give me some advice on how to get the data out?
UPDATE and interim solution:
To get json values I had to do one of two things:
use ls Replace functions to extract the single dimension data (ie, remove {"colorsArray":[ on the left side and ]} on the right side., then use snapps json reader.
I created a java library using the SBT JSON libs and called it from LotusScript. Paul Bastide put a good writeup on using the java lib http://bastide.org/2014/03/15/using-the-ibm-social-business-toolkit-to-process-json-objects/
Here is the java code:
import com.ibm.commons.util.io.json.JsonException;
import com.ibm.commons.util.io.json.JsonJavaFactory;
import com.ibm.commons.util.io.json.JsonJavaObject;
import com.ibm.commons.util.io.json.JsonParser;
import com.ibm.sbt.services.client.base.datahandlers.JsonDataHandler;
import lotus.domino.*;
public class GetJSON extends AgentBase {
public static String pJSON( String jData, String jEntry, String jValue ) {
String result2="";
try {
System.out.println("data: " + jData + "\n" + "\n" + "jEntry & jValue: " + jEntry + ", " + jValue);
// print to debug console
// System.out.println("jData: " + jData);
JsonJavaObject jsonObject = (JsonJavaObject) JsonParser.fromJson(JsonJavaFactory.instanceEx, jData );
JsonDataHandler handler = new JsonDataHandler();
handler.setData(jsonObject);
JsonJavaObject entryJson=handler.getEntry(jEntry);
result2=entryJson.getAsString(jValue);
} catch (Exception e) {
System.out.println("Error: " + e);
e.printStackTrace();
result2="";
}
return result2; }
}
and I call it from LotusScript as follows:
Option Public
Option Declare
Use "($getJson)"
UseLSX "*javacon"
Dim mySession As JavaSession
Dim myClass As JavaClass
Dim getJson As JavaObject
result = ""
'....
'add vars here
'....
Set mySession = New JavaSession()
Set myClass = mySession.GetClass("GetJSON")
Set GetJson = myClass.CreateObject()
MsgBox GetJson.pJSON( result2, "colorsArray", "red" )
IMPORTANT NOTE on the above, in the array string I had to remove the brackets [ and ] because I was getting an SBT array incompatibility error in java. I think by doing that it may have turned it into a single level object, but if you look at Paul's example from above URL, you'll see he doesn't add them to his example either.
I would rather do this in all Java or all LotusScript, and will probably use the modified json string with snapps, just looking for a better solution.
Here is the working code for your JSON string. Try it.
Dim jsonReader As JSONReader
Dim vResults As Variant
Dim vPieces As Variant
Dim sJSON As String
sJson= |{ "colorsArray":[{
"red":"#f00",
"green":"#0f0",
"blue":"#00f",
"cyan":"#0ff",
"magenta":"#f0f",
"yellow":"#ff0",
"black":"#000"
}
]}|
Set jsonReader = New JSONReader
Set vResults = jsonReader.parse(sJson)
Set vResultData = vResults.GetItemValue("colorsArray")
Forall vResult In vResultData.Items
Msgbox Cstr(vResult.GetItemValue("red"))
Msgbox Cstr(vResult.GetItemValue("green"))
Msgbox Cstr(vResult.GetItemValue("blue"))
Msgbox Cstr(vResult.GetItemValue("cyan"))
Msgbox Cstr(vResult.GetItemValue("magenta"))
Msgbox Cstr(vResult.GetItemValue("yellow"))
Msgbox Cstr(vResult.GetItemValue("black"))
End Forall

Problem in Copying the data one Excel to another Excel using VBSCript

I have an excel sheet which contains around 1000 lines of data, i have copy these data to another sheet which satisfy the condition. In order to achieve this i have written a script,
For m = 1 To x2 'iterate single column
For n = 1 To x4 'iterate PM_DUMP
If InStr(PMSheet.cells(n,6).value, dupSingle.cells(m,1).value) > 0 Then
' For p = 1 To y4
wsc.Activate
wsc.Rows.Item(n).Select
wsc.Application.Selection.Copy
wsb.Activate
wsb.Rows(m).Select
wsb.paste
wsc.Application.CutCopyMode = False
On Error Resume Next
Exit For
End If
Next
Next
GetExcel2.Save
The execution of the script goes well up to certian limit say 350 rows the next row was getting copied fine but the entire row was highlight in Red Color after few minutes, I am getting an error " An EXCEL Encountered an error " then it closes the workbook and opens a new sheet without any data...
Any help to resolve this issue is much appreciated.
With Regards,
Ramesh.T
Try combining the copy and pasting into a single step. Replace all this code
wsc.Activate
wsc.Rows.Item(n).Select
wsc.Application.Selection.Copy
wsb.Activate
wsb.Rows(m).Select
wsb.paste
wsc.Application.CutCopyMode = False
wsc.Application.CutCopyMode = False
On Error Resume Next
with
wsc.Rows(n).Copy wsb.Rows(m)
I have, on occasion, found it simpler to deal with Excel data through an OLEDB interface. Then you simply treat two sheets as two tables, with standard DataTable operations instead of the more fickle Automation operations. I only have a ready example for reading data, but hopefully you can extrapolate writing operations as well:
/// <summary>
/// Reads an Excel spreadsheet into a new DataTable.
/// </summary>
/// <param name="xlsFile">The full file path of the Excel workbook to read from.</param>
/// <param name="sheetName">The name of the sheet in the workbook to read.</param>
/// <param name="tableName">The name to give the new DataTable that the spreadsheet is read into.</param>
/// <param name="firstRowIsHeader">Indicates wheather or not the first row of the spreadsheet is a header row.</param>
/// <returns></returns>
internal static DataTable XlsToDataTable(string xlsFile, string sheetName, string tableName, bool firstRowIsHeader)
{
var dt = new DataTable(tableName);
var yesNo = firstRowIsHeader ? "Yes" : "No";
string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + xlsFile + ";Extended Properties='Excel 8.0;HDR=" + yesNo + ";IMEX=1';";
using (var ocn = new OleDbConnection(connStr ))
{
var cmd = new OleDbCommand("Select * from [" + sheetName + "$]", ocn);
var datadapt = new OleDbDataAdapter {SelectCommand = cmd};
datadapt.Fill(dt);
}
return dt;
}
It's my experience that the .Paste doesn't work that well, so I'd recommend that you change
wsb.paste
to
wsb.pastespecial
Do you still have problems if you change that?
UPDATE:
I'm not sure if this will make any difference in the execution, but I think the middle section is more complicated than it needs to be - does it work if you replace the middle section of the loop with this code:
wsc.Activate
wsc.Rows(m).Item.Copy
wsb.Activate
wsb.Rows(n).PasteSpecial
That way, you also won't need to set the CutCopyMode = False until you're totally done with the loops, so it should be faster.

Multiline strings in VB.NET

Is there a way to have multiline strings in VB.NET like Python
a = """
multi
line
string
"""
or PHP?
$a = <<<END
multi
line
string
END;
Of course something that is not
"multi" & _
"line
You can use XML Literals to achieve a similar effect:
Imports System.XML
Imports System.XML.Linq
Imports System.Core
Dim s As String = <a>Hello
World</a>.Value
Remember that if you have special characters, you should use a CDATA block:
Dim s As String = <![CDATA[Hello
World & Space]]>.Value
2015 UPDATE:
Multi-line string literals were introduced in Visual Basic 14 (in Visual Studio 2015). The above example can be now written as:
Dim s As String = "Hello
World & Space"
MSDN article isn't updated yet (as of 2015-08-01), so check some answers below for details.
Details are added to the Roslyn New-Language-Features-in-VB-14 Github repository.
VB.Net has no such feature and it will not be coming in Visual Studio 2010. The feature that jirwin is refering is called implicit line continuation. It has to do with removing the _ from a multi-line statement or expression. This does remove the need to terminate a multiline string with _ but there is still no mult-line string literal in VB.
Example for multiline string
Visual Studio 2008
Dim x = "line1" & vbCrlf & _
"line2"
Visual Studio 2010
Dim x = "line1" & vbCrlf &
"line2"
I used this variant:
Dim query As String = <![CDATA[
SELECT
a.QuestionID
FROM
CR_Answers a
INNER JOIN
CR_Class c ON c.ClassID = a.ClassID
INNER JOIN
CR_Questions q ON q.QuestionID = a.QuestionID
WHERE
a.CourseID = 1
AND
c.ActionPlan = 1
AND q.Q_Year = '11/12'
AND q.Q_Term <= (SELECT CurrentTerm FROM CR_Current_Term)
]]>.Value()
it allows < > in the string
Multi-line strings are available since the Visual Studio 2015.
Dim sql As String = "
SELECT ID, Description
FROM inventory
ORDER BY DateAdded
"
You can combine them with string interpolation to maximize usefullness:
Dim primaryKey As String = "ID"
Dim inventoryTable As String = "inventory"
Dim sql As String = $"
SELECT {primaryKey}, Description
FROM {inventoryTable}
ORDER BY DateAdded
"
Note that interpolated strings begin with $ and you need to take care of ", { and } contained inside – convert them into "", {{ or }} respectively.
Here you can see actual syntax highlighting of interpolated parts of the above code example:
If you wonder if their recognition by the Visual Studio editor also works with refactoring (e.g. mass-renaming the variables), then you are right, code refactoring works with these. Not mentioning that they also support IntelliSense, reference counting or code analysis.
Multiline string literals are introduced in Visual Basic 14.0 - https://roslyn.codeplex.com/discussions/571884
You can use then in the VS2015 Preview, out now - http://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs (note that you can still use VS2015 even when targeting an older version of the .NET framework)
Dim multiline = "multi
line
string"
VB strings are basically now the same as C# verbatim strings - they don't support backslash escape sequences like \n, and they do allow newlines within the string, and you escape the quote symbol with double-quotes ""
this was a really helpful article for me, but nobody mentioned how to concatenate in case you want to send some variables, which is what you need to do 99% of the time.
... <%= variable %> ...
Here's how you do it:
<SQL>
SELECT * FROM MyTable WHERE FirstName='<%= EnteredName %>'
</SQL>.Value
Well, since you seem to be up on your python, may I suggest that you copy your text into python, like:
s="""this is gonna
last quite a
few lines"""
then do a:
for i in s.split('\n'):
print 'mySB.AppendLine("%s")' % i
# mySB.AppendLine("this is gonna")
# mySB.AppendLine("last quite a")
# mySB.AppendLine("few lines")
or
print ' & _ \n'.join(map(lambda s: '"%s"' % s, s.split('\n')))
# "this is gonna" & _
# "last quite a" & _
# "few lines"
then at least you can copy that out and put it in your VB code. Bonus points if you bind a hotkey
(fastest to get with:Autohotkey) to do this for for whatever is in your paste buffer. The same idea works well for a SQL formatter.
Multi-line string literals in vb.net using the XElement class.
Imports System.Xml.Linq
Public Sub Test()
dim sOderBy as string = ""
dim xe as XElement = <SQL>
SELECT * FROM <%= sTableName %>
<ORDER_BY> ORDER BY <%= sOrderBy %></ORDER_BY>
</SQL>
'** conditionally remove a section
if sOrderBy.Length = 0 then xe.<ORDER BY>.Remove
'** convert XElement value to a string
dim sSQL as String = xe.Value
End Sub
To me that is the most annoying thing about VB as a language.
Seriously, i once wrote the string in a file and wrote code something along the lines of:
Dim s as String = file_get_contents("filename.txt")
just so i could test the query directly on SQL server if i need to.
My current method is to use a stored procedure on the SQL Server and just call that so i can pass in parameters to the query, etc
I figured out how to use both <![CDATA[ along with <%= for variables, which allows you to code without worry.
You basically have to terminate the CDATA tags before the VB variable and then re-add it after so the CDATA does not capture the VB code. You need to wrap the entire code block in a tag because you will you have multiple CDATA blocks.
Dim script As String = <code><![CDATA[
<script type="text/javascript">
var URL = ']]><%= domain %><![CDATA[/mypage.html';
</script>]]>
</code>.value
You could (should?) put the string in a resource-file (e.g. "My Project"/Resources) and then get it with
Dim a = My.Resources.Whatever_you_chose
Disclaimer: I love python. It's multi-line strings are only one reason.
But I also do VB.Net, so here's my short-cut for more readable long strings.
Dim lines As String() = {
"Line 1",
"Line 2",
"Line 3"
}
Dim s As String = Join(lines, vbCrLf)
you can use XML for this like
dim vrstr as string = <s>
some words
some words
some
words
</s>
in Visual studio 2010 (VB NET)i try the following and works fine
Dim HtmlSample As String = <anything>what ever you want to type here with multiline strings</anything>
dim Test1 as string =<a>onother multiline example</a>
Available in Visual Basic 14 as part of Visual Studio 2015
https://msdn.microsoft.com/en-us/magazine/dn890368.aspx
But not yet supported by R#. The good news is they will be supported soon! Please vote on Youtrack to notify JetBrains you need them also.
If you need an XML literal in VB.Net with an line code variable, this is how you would do it:
<Tag><%= New XCData(T.Property) %></Tag>
Since this is a readability issue, I have used the following code:
MySql = ""
MySql = MySql & "SELECT myTable.id"
MySql = MySql & " FROM myTable"
MySql = MySql & " WHERE myTable.id_equipment = " & lblId.Text
You can also use System.Text.StringBuilder class in this way:
Dim sValue As New System.Text.StringBuilder
sValue.AppendLine("1st Line")
sValue.AppendLine("2nd Line")
sValue.AppendLine("3rd Line")
Then you get the multiline string using:
sValue.ToString()
Use vbCrLf or vbNewLine. It works with MessageBoxes and many other controls I tested.
Dim str As String
str = "First line" & vbCrLf & "Second line"
MsgBox(str)
str = "First line" & vbNewLine & "Second line"
MsgBox(str)
It will show two identical MessageBoxes with 2 lines.
No, VB.NET does not yet have such a feature. It will be available in the next iteration of VB (visual basic 10) however (link)
if it's like C# (I don't have VB.Net installed) you can prefix a string with #
foo = #"Multiline
String"
this is also useful for things like #"C:\Windows\System32\" - it essentially turns off escaping and turns on multiline.

Resources