Reduce line continuation in excel - vba

I'm trying to make excel create XML files using VBA (that my first time), so I managed to create a code but I keep getting the message that there are too many line continuations
Here is my code
Sub testXLStoXML()
sTemplateXML = _
"<?xml version='1.0'?>" + vbNewLine + _
"<offers>" + vbNewLine + _
" <offer>" + vbNewLine + _
" <offer_identifier>" + vbNewLine + _
" </offer_identifier>" + vbNewLine + _
" <offer_title>" + vbNewLine + _
" </offer_title>" + vbNewLine + _
" <offer_description>" + vbNewLine + _
" </offer_description>" + vbNewLine + _
" <offer_featured_image>" + vbNewLine + _
" </offer_featured_image>" + vbNewLine + _
" <offer_cat>" + vbNewLine + _
" </offer_cat>" + vbNewLine + _
" <offer_location>" + vbNewLine + _
" </offer_location>" + vbNewLine + _
" <offer_tags>" + vbNewLine + _
" </offer_tags>" + vbNewLine + _
" <offer_type>" + vbNewLine + _
" </offer_type>" + vbNewLine + _
" <offer_start>" + vbNewLine + _
" </offer_start>" + vbNewLine + _
" <offer_expire>" + vbNewLine + _
" </offer_expire>" + vbNewLine + _
" <offer_store>" + vbNewLine + _
" </offer_store>" + vbNewLine + _
" <!-- store -->" + vbNewLine + _
" <store_title>" + vbNewLine + _
" </store_title>" + vbNewLine + _
" <store_letter>" + vbNewLine + _
" </store_letter>" + vbNewLine + _
" <store_description>" + vbNewLine + _
" </store_description>" + vbNewLine + _
" <store_logo>" + vbNewLine + _
" </store_logo>" + vbNewLine + _
" <store_link>" + vbNewLine + _
" </store_link>" + vbNewLine + _
" <store_facebook>" + vbNewLine + _
" </store_facebook>" + vbNewLine + _
" <store_twitter>" + vbNewLine + _
" </store_twitter>" + vbNewLine + _
" <store_google>" + vbNewLine + _
" </store_google>" + vbNewLine + _
" <!-- store -->" + vbNewLine + _
" <!-- DEAL RELATED -->" + vbNewLine + _
" <deal_items>" + vbNewLine + _
" </deal_items>" + vbNewLine + _
" <deal_item_vouchers>" + vbNewLine + _
" </deal_item_vouchers>" + vbNewLine + _
" <deal_price>" + vbNewLine + _
" </deal_price>" + vbNewLine + _
" <deal_sale_price>" + vbNewLine + _
" </deal_sale_price>" + vbNewLine + _
" <deal_discount>" + vbNewLine + _
" </deal_discount>" + vbNewLine + _
" <deal_voucher_expire>" + vbNewLine + _
" </deal_voucher_expire>" + vbNewLine + _
" <deal_in_short>" + vbNewLine + _
" </deal_in_short>" + vbNewLine + _
" <deal_type>" + vbNewLine + _
" </deal_type>" + vbNewLine + _
" <deal_link>" + vbNewLine + _
" </deal_link>" + vbNewLine + _
" </offer>" + vbNewLine + _
"</offers>" + vbNewLine +
Is there a way to bypass the limit or make this work?

Per Microsoft, "There is a limit to the number of lines you can join with line-continuation characters. This error has the following cause and solution:
Your code has more than 25 physical lines lines joined with line-continuation characters, or more than 24 consecutive line-continuation characters in a single line. Make some of the constituent lines physically longer to reduce the number of line-continuation characters needed, or break the construct into more than one statement."
The line continuations are merely for ease of reading the code and are necessary to have after each tag the way you have it now

Related

Problem with Splitting Values and Looping

I'm trying to split certain values in Excel using VB and then creating an XML document using the getelementsbytagname to create the structure of the file. I have it splitting at the semicolon for the Creator, Subject, and Contributors fields in Excel. This does work but i would like to have separate tags for each entry that was split. Currently, all the entries are in one tag separated by semicolon. I'm able to split the values correctly but I get a mismatch error 13 on the doc.getElementsByTagName("Creator")(0).appendChild doc.createTextNode(sCreator), which is the first field that I try to split. Is there a way to create a loop in the below code so it would go through the code and add separate XML tags for each field that I'm splitting (Creator, Subject, Contributors)?
Sub XLStoXML()
sTemplateXML = _
"<?xml version='1.0' encoding='UTF-8'?>" + vbNewLine + _
"<odu xmlns='https://dc.lib.odu.edu'>" + vbNewLine + _
" <Identifier>" + vbNewLine + _
" </Identifier>" + vbNewLine + _
" <Title>" + vbNewLine + _
" </Title>" + vbNewLine + " <Creator>" + vbNewLine + " </Creator>" + vbNewLine + " <Subject>" + vbNewLine + " </Subject>" + " <Description>" + vbNewLine + " </Description>" + vbNewLine + " <Contributors>" + vbNewLine + " </Contributors>" + vbNewLine + _
" <Publisher>" + vbNewLine + " </Publisher>" + vbNewLine + " <Date>" + vbNewLine + " </Date>" + vbNewLine + " <Coverage>" + vbNewLine + " </Coverage>" + vbNewLine + _
" <Language>" + vbNewLine + " </Language>" + vbNewLine + " <Languagecode>" + vbNewLine + " </Languagecode>" + vbNewLine + " <Source>" + vbNewLine + " </Source>" + vbNewLine + " <Findingaid>" + vbNewLine + " </Findingaid>" + vbNewLine + _
" <RightsStatement>" + vbNewLine + " </RightsStatement>" + vbNewLine + " <Rightsholder>" + vbNewLine + " </Rightsholder>" + vbNewLine + " <Disclaimer>" + vbNewLine + " </Disclaimer>" + vbNewLine + " <Contributinginstitution>" + vbNewLine + " </Contributinginstitution>" + vbNewLine + _
" <Electronicpublisher>" + vbNewLine + " </Electronicpublisher>" + vbNewLine + " <Format>" + vbNewLine + " </Format>" + vbNewLine + " <Mediaformat>" + vbNewLine + " </Mediaformat>" + vbNewLine + " <Resourcetype>" + vbNewLine + " </Resourcetype>" + vbNewLine + " <Datedigital>" + vbNewLine + " </Datedigital>" + vbNewLine + _
" <Filesize>" + vbNewLine + " </Filesize>" + vbNewLine + " <Collection>" + vbNewLine + " </Collection>" + vbNewLine + " <Digitizedby>" + vbNewLine + " </Digitizedby>" + vbNewLine + " <Digitalcollection>" + vbNewLine + " </Digitalcollection>" + vbNewLine + " <Digitalrepository>" + vbNewLine + " </Digitalrepository>" + vbNewLine + _
" <Transcript>" + vbNewLine + " </Transcript>" + vbNewLine + " <Filename>" + vbNewLine + " </Filename>" + vbNewLine + _
"</odu>" + vbNewLine
Set doc = CreateObject("MSXML2.DOMDocument")
doc.async = False
doc.validateOnParse = False
doc.resolveExternals = False
With ActiveWorkbook.Worksheets(1)
lLastRow = .UsedRange.Rows.Count
For lRow = 2 To lLastRow
sFile = .Cells(lRow, 1).Value
sIdentifier = .Cells(lRow, 2).Value
sTitle = .Cells(lRow, 3).Value
Dim sCreator() As String
sCreator = Split(.Cells(lRow, 4), ";")
Dim sSubject() As String
sSubject = Split(.Cells(lRow, 5).Value, ";")
sDescription = .Cells(lRow, 6).Value
Dim sContributors() As String
sContributors = Split(.Cells(lRow, 7).Value, ";")
sPublisher = .Cells(lRow, 8).Value
sDate = .Cells(lRow, 9).Value
sCoverage = .Cells(lRow, 10).Value
sLanguage = .Cells(lRow, 11).Value
sLanguagecode = .Cells(lRow, 12).Value
sSource = .Cells(lRow, 13).Value
sFindingaid = .Cells(lRow, 14).Value
sRightsStatement = .Cells(lRow, 15).Value
sRightsholder = .Cells(lRow, 16).Value
sDisclaimer = .Cells(lRow, 17).Value
sContributinginstitution = .Cells(lRow, 18).Value
sElectronicpublisher = .Cells(lRow, 19).Value
sFormat = .Cells(lRow, 20).Value
sMediaformat = .Cells(lRow, 21).Value
sResourcetype = .Cells(lRow, 22).Value
sDatedigital = .Cells(lRow, 23).Value
sFilesize = .Cells(lRow, 24).Value
sCollection = .Cells(lRow, 25).Value
sDigitizedby = .Cells(lRow, 26).Value
sDigitalcollection = .Cells(lRow, 27).Value
sDigitalrepository = .Cells(lRow, 28).Value
sTranscript = .Cells(lRow, 29).Value
sFilename = .Cells(lRow, 30).Value
doc.LoadXML sTemplateXML
doc.getElementsByTagName("Identifier")(0).appendChild doc.createTextNode(sIdentifier)
doc.getElementsByTagName("Title")(0).appendChild doc.createTextNode(sTitle)
doc.getElementsByTagName("Creator")(0).appendChild doc.createTextNode(sCreator)
doc.getElementsByTagName("Subject")(0).appendChild doc.createTextNode(sSubject)
doc.getElementsByTagName("Description")(0).appendChild doc.createTextNode(sDescription)
doc.getElementsByTagName("Contributors")(0).appendChild doc.createTextNode(sContributors)
doc.getElementsByTagName("Publisher")(0).appendChild doc.createTextNode(sPublisher)
doc.getElementsByTagName("Date")(0).appendChild doc.createTextNode(sDate)
doc.getElementsByTagName("Coverage")(0).appendChild doc.createTextNode(sCoverage)
doc.getElementsByTagName("Language")(0).appendChild doc.createTextNode(sLanguage)
doc.getElementsByTagName("Languagecode")(0).appendChild doc.createTextNode(sLanguagecode)
doc.getElementsByTagName("Source")(0).appendChild doc.createTextNode(sSource)
doc.getElementsByTagName("Findingaid")(0).appendChild doc.createTextNode(sFindingaid)
doc.getElementsByTagName("RightsStatement")(0).appendChild doc.createTextNode(sRights)
doc.getElementsByTagName("Rightsholder")(0).appendChild doc.createTextNode(sRightsholder)
doc.getElementsByTagName("Disclaimer")(0).appendChild doc.createTextNode(sDisclaimer)
doc.getElementsByTagName("Contributinginstitution")(0).appendChild doc.createTextNode(sContributinginstitution)
doc.getElementsByTagName("Electronicpublisher")(0).appendChild doc.createTextNode(sElectronicpublisher)
doc.getElementsByTagName("Format")(0).appendChild doc.createTextNode(sFormat)
doc.getElementsByTagName("Mediaformat")(0).appendChild doc.createTextNode(sMediaformat)
doc.getElementsByTagName("Resourcetype")(0).appendChild doc.createTextNode(sResourcetype)
doc.getElementsByTagName("Datedigital")(0).appendChild doc.createTextNode(sDatedigital)
doc.getElementsByTagName("Filesize")(0).appendChild doc.createTextNode(sFilesize)
doc.getElementsByTagName("Collection")(0).appendChild doc.createTextNode(sCollection)
doc.getElementsByTagName("Digitizedby")(0).appendChild doc.createTextNode(sDigitizedby)
doc.getElementsByTagName("Digitalcollection")(0).appendChild doc.createTextNode(sDigitalcollection)
doc.getElementsByTagName("Digitalrepository")(0).appendChild doc.createTextNode(sDigitalrepository)
doc.getElementsByTagName("Transcript")(0).appendChild doc.createTextNode(sTranscript)
doc.getElementsByTagName("Filename")(0).appendChild doc.createTextNode(sFilename)
doc.Save sFile
Next
End With
End Sub
Since is was a mismatch error 13, I tried changing those three tags to a string type but that didn't work

MS Access VBA Data Type Mismatch Error in SQL Query

I currently have the following MS Access SQL Query which is part of an Access VBA function. It has been built with help from a previous question, which you can look at to better understand how it works.
sqlJoinQuery = "SELECT tbl_grp_by.[Field1],tbl_grp_by.[Field2], " & _
"Switch( " & _
"Nz(tbl_grp_by.[maxfield3]) = 0, '0', " & _
"Nz(tbl_grp_by.[maxfield3]) = 1, '>1 million', " & _
"Nz(tbl_grp_by.[maxfield3]) = 2, '0001-0010' " & _
") as [Field3], " & _
"tbl_grp_by.[" + commonField + "], " & _
"[" + tableName + "].* " & _
"INTO [" + newTableName + "] FROM (" & _
"SELECT Max([" + tableNameTemp + "].[Field1]) as [Field1], " & _
"Max([" + tableNameTemp + "].[Field2]) as [Field2], " & _
"Max(Switch( " & _
"Nz([" + tableNameTemp + "].[Field3]) = '0' , 0, " & _
"Nz([" + tableNameTemp + "].[Field3]) = '>1 million' , 1, " & _
"Nz([" + tableNameTemp + "].[Field3]) = '0001-0010', 2 " & _
"))as [maxField3], " & _
"[" + tableNameTemp + "].[" + commonField + "] as [" + commonField + "] " & _
"FROM [" + tableNameTemp + "] " & _
"INNER JOIN [" + tableName + "] " & _
"ON [" + tableNameTemp + "].[" + commonField + "] = [" + tableName + "].[" + commonField + "] " & _
"GROUP BY [" + tableNameTemp + "].[" + commonField + "] " & _
") as tbl_grp_by " & _
"INNER JOIN [" + tableName + "] " & _
"ON [" + tableName + "].[" + commonField + "] = tbl_grp_by.[" + commonField + "]"
The above Access query results in this SQL String:
SELECT tbl_grp_by.[Field1],
tbl_grp_by.[Field2],
Switch(Nz(tbl_grp_by.[maxfield3]) = 0, '0', Nz(tbl_grp_by.[maxfield3]) = 1, '>1 million', Nz(tbl_grp_by.[maxfield3]) = 2, '0001-0010') AS [Field3],
tbl_grp_by.[Finding ID],
[Issue_Management_Findings].* INTO [region_Issue_Management_Findings]
FROM
(SELECT Max([temp2_temp_Issue_Management_Findings].[Field1]) AS [Field1],
Max([temp2_temp_Issue_Management_Findings].[Field2]) AS [Field2],
Max(Switch(Nz([temp2_temp_Issue_Management_Findings].[Field3]) = '0', 0, Nz([temp2_temp_Issue_Management_Findings].[Field3]) = '>1 million', 1, Nz([temp2_temp_Issue_Management_Findings].[Field3]) = '0001-0010', 2))AS [maxField3],
[temp2_temp_Issue_Management_Findings].[Finding ID] AS [Finding ID]
FROM [temp2_temp_Issue_Management_Findings]
INNER JOIN [Issue_Management_Findings] ON Nz([temp2_temp_Issue_Management_Findings].[Finding ID]) = Nz([Issue_Management_Findings].[Finding ID])
GROUP BY [temp2_temp_Issue_Management_Findings].[Finding ID]) AS tbl_grp_by
INNER JOIN [Issue_Management_Findings] ON Nz([Issue_Management_Findings].[Finding ID]) = Nz(tbl_grp_by.[Finding ID])
So [Field3] is encoded under max() in the inner query and that max is decoded in outer query.
However, when I run it I get the following error:
Run-time error '3464': Data type mismatch in criteria expression
If I copy my SQL query from debug output in the immediate window and paste it in a manual SQL query (after running my VBA code up to a breakpoint where the SQL query should be run), then I get the following error:
Data type mismatch in criteria expression
If I only run the subquery in my above SQL string for debugging purposes:
(SELECT Max([temp2_temp_Issue_Management_Findings].[Field1]) AS [Field1],
Max([temp2_temp_Issue_Management_Findings].[Field2]) AS [Field2],
Max(Switch(Nz([temp2_temp_Issue_Management_Findings].[Field3]) = '0', 0, Nz([temp2_temp_Issue_Management_Findings].[Field3]) = '>1 million', 1, Nz([temp2_temp_Issue_Management_Findings].[Field3]) = '0001-0010', 2))AS [maxField3],
[temp2_temp_Issue_Management_Findings].[Finding ID] AS [Finding ID]
FROM [temp2_temp_Issue_Management_Findings]
INNER JOIN [Issue_Management_Findings] ON Nz([temp2_temp_Issue_Management_Findings].[Finding ID]) = Nz([Issue_Management_Findings].[Finding ID])
GROUP BY [temp2_temp_Issue_Management_Findings].[Finding ID])
Then it runs without error
Note that Issue_Management_Findings is the name of an existing table in the database.
Does anybody know how I could fix these errors?
I think you have to add default return value on your Switch just in case it fails to match all the other criteria so it wont return Null which I believe cause the Data Type mismatch issue. You can just add ...,true,"thedefaultvalue") e.g.
SWITCH (field>100, "greater", field3=100 ,"equals", true, "default")
so in your query. I default it to 0;
sqlJoinQuery = "SELECT tbl_grp_by.[Field1],tbl_grp_by.[Field2], " & _
"Switch( " & _
"Nz(tbl_grp_by.[maxfield3]) = 0, '0', " & _
"Nz(tbl_grp_by.[maxfield3]) = 1, '>1 million', " & _
"Nz(tbl_grp_by.[maxfield3]) = 2, '0001-0010' " & _
", true,'0') as [Field3], " & _
"tbl_grp_by.[" + commonField + "], " & _
"[" + tableName + "].* " & _
"INTO [" + newTableName + "] FROM (" & _
"SELECT Max([" + tableNameTemp + "].[Field1]) as [Field1], " & _
"Max([" + tableNameTemp + "].[Field2]) as [Field2], " & _
"Max(Switch( " & _
"Nz([" + tableNameTemp + "].[Field3]) = '0' , 0, " & _
"Nz([" + tableNameTemp + "].[Field3]) = '>1 million' , 1, " & _
"Nz([" + tableNameTemp + "].[Field3]) = '0001-0010', 2 " & _
", true, 0))as [maxField3], " & _
"[" + tableNameTemp + "].[" + commonField + "] as [" + commonField + "] " & _
"FROM [" + tableNameTemp + "] " & _
"INNER JOIN [" + tableName + "] " & _
"ON [" + tableNameTemp + "].[" + commonField + "] = [" + tableName + "].[" + commonField + "] " & _
"GROUP BY [" + tableNameTemp + "].[" + commonField + "] " & _
") as tbl_grp_by " & _
"INNER JOIN [" + tableName + "] " & _
"ON [" + tableName + "].[" + commonField + "] = tbl_grp_by.[" + commonField + "]"

Sending Email within loop in a function

code is building the email but it is only displaying one row when there is six. I got it correct on the text file but I need it to do the same in the email message. I think I got the for next statement in the wrong location. Here is the example of the code that I am having problem with. I do not know how to place the for next statement without interrupting the vbLine
For Each p In query
If p.Contract_No IsNot Nothing Then
ContractNo = p.Contract_No
Else
ContractNo = " "
End If
If p.Vendor_Name IsNot Nothing Then
VenderName = p.Vendor_Name
Else
VenderName = " "
End If
If p.Termination_Date IsNot Nothing Then
TerminationDate = p.Termination_Date
' ReportDateStr = ReportDate.ToString
TerminationDateStr = String.Format("{0:MM/dd/yyyy}", TerminationDate)
Else
TerminationDateStr = " "
End If
If p.Dept_Name IsNot Nothing Then
DeptName = p.Dept_Name
Else
DeptName = " "
End If
If p.Renewal_Option_Desc IsNot Nothing Then
RenewalOption = p.Renewal_Option_Desc
Else
RenewalOption = " "
End If
If p.Contract_Desc IsNot Nothing Then
ContractDesc = p.Contract_Desc
Else
ContractDesc = " "
End If
If p.Contact_Email IsNot Nothing Then
ContactEmail = p.Contact_Email
Else
ContactEmail = "** N/A ** "
End If
' sends email with attachment
EmailMsgBody = "-- TOTAL # OF CONTRACTS WITH FAILSAFE DATE ON " + DateStr + " IS: " + icnt.ToString + vbCrLf +
vbNewLine + " __________________ " +
vbNewLine +
vbNewLine + " *****Contracts**** " +
vbNewLine + " __________________ " +
vbNewLine +
vbNewLine + "Contract#" + " " + "Vender Name" + " " + "Termination Date" + " " + "Dept Name" + " " + "Renewal Option" + " " + "Contract Desc" + " " + "Email Address" +
vbNewLine + "------------" + " " + "-----------------" + " " + "---------------------" + " " + "--------------" + " " + "--------------------" + " " + "-----------------" + " " + "-----------------" +
vbNewLine + ContractNo.PadRight(18) + " " + _
VenderName.PadRight(38) + " " + _
TerminationDateStr.PadRight(26) + " " + _
DeptName.PadRight(27) + " " + _
RenewalOption.PadRight(45) + " " + _
ContractDesc.PadRight(32) + " " + _
ContactEmail.PadRight(11) + " "

SQL query in 2012 works, 2005 does not

I have the following query that i need help with converting it to syntax that MS SQL 2005 would understand since FORMAT among other things in it are not supported by that old version.
"SELECT " & _
"TMP.*," & _
"COUNT(*) OVER () AS rCount " & _
"FROM (" & _
"SELECT venueID, " & _
"venueName AS venueName, " & _
"venueAddress + ', ' + venueCity + ', ' + venueState + ' ' + venueZip AS venueAddress, " & _
"venueLatLong AS coordinates, " & _
"FORMAT(venueEventDate, 'MM/dd/yyyy', 'en-US') + ' # ' + CONVERT(VARCHAR,venueTime) AS dateAndTime, " & _
"SUBSTRING(venueLatLong, 1, CHARINDEX(',', venueLatLong)-1) AS Lat, " & _
"SUBSTRING(venueLatLong, CHARINDEX(',', venueLatLong) + 1, 1000) AS Lng, " & _
"(round(" & _
"3959 * acos " & _
"(" & _
"cos(radians('" & center_lat & "')) " & _
"* cos(radians(SUBSTRING(venueLatLong, 1, CHARINDEX(',', venueLatLong)-1))) " & _
"* cos(radians(SUBSTRING(venueLatLong, CHARINDEX(',', venueLatLong) + 1, 1000)) " & _
"- radians('" & center_lng & "')) " & _
"+ sin(radians('" & center_lat & "')) " & _
"* sin(radians(SUBSTRING(venueLatLong, 1, CHARINDEX(',', venueLatLong)-1)))" & _
")" & _
", 1, 1)) AS distance " & _
"FROM meetUpMarkers) " & _
"TMP " & _
"WHERE distance < " & radius & " " & _
"ORDER BY venueName,distance DESC;"
I tried to replace FORMAT with CONVERT but it still seems to be incorrect.
When i change FORMAT to CONVERT i get the error:
Type venueEventDate is not a defined system type.
UPDATE
Uggg... now when I run it local i get this:
Now even when i run it local i get this error???!??! and its 2012:
Msg 8114, Level 16, State 5, Line 2
Error converting data type varchar to float.
Does this mean line 2, word 5 has the error?
Would appreciate the help.
Arguments for FORMAT() and CONVERT() are in a different order. The error message indicates you put the field name into the data type argument position. It's:
FORMAT ( value, format [, culture ] )
vs
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )
Try replacing FORMAT(venueEventDate, 'MM/dd/yyyy', 'en-US') with this:
CONVERT(VARCHAR, venueEventDate, 101)`

How To Make A File Be Named From A Texbox in VB

Im trying to get a file to be created and named when a button is pressed. But I need the file name to contain text from a textbox.
Code:
My.Computer.FileSystem.WriteAllText("c:\temp\" + txtUser.Text + ".txt", "[" + TimeOfDay + "]" + "Email: " + txtEmail.Text + vbNewLine + "Username: " + txtUser.Text + vbNewLine + "Password: " + txtPass.Text + vbNewLine + "Secuirty: " + txtSecuirty.Text + vbNewLine + vbNewLine, True)
Simple Code:
My.Computer.FileSystem.WriteAllText("c:\temp\" + txtUser.Text + ".txt", {loads of stuff}, True)
I have loads of if functions, to stop the disallowed characters.
The error I am getting is:
Expression does not produce a value
Try to see if this will work for you.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
My.Computer.FileSystem.WriteAllText("c:\temp\" + txtUser.Text.ToString() + ".txt", "test message", True)
End Sub
Or you can change your code to
Dim strFileText As String = ""
strFileText =
"[" & TimeOfDay.ToString() & "] " & vbCrLf &
"Email: " & txtEmail.Text.ToString() & vbCrLf &
"Username: " & txtUser.Text.ToString() & vbCrLf &
"Password: " & txtPass.Text.ToString() & vbCrLf &
"Security: " & txtSecurity.Text.ToString() & vbCrLf & vbCrLf
My.Computer.FileSystem.WriteAllText("c:\temp\" + txtUser.Text.ToString() + ".txt", strFileText, True)