Im building a program that helps with php code. It has a ton of lines, so i need to add & VbCrLf & _ to the end of every line. Can i make a program that does this for me?
Printable View
Im building a program that helps with php code. It has a ton of lines, so i need to add & VbCrLf & _ to the end of every line. Can i make a program that does this for me?
Yup, you can!
-Max :D
=o
Stop messin with me, man!
May you teach me how?
Each end of line is a VbCrLf character (a line break), so you can use Replace function to do something like this
strData = Replace(strData, vbCrLf, vbCrLf & " & VbCrLf & _")
if I understood correctly, that you wanted to append that as string, if not just change it to match what you want.
Now, most of the lines have & VbCrLf & _ in front of them.
However, only the first line has black text and all the other lines have red text (error). It also added a " to the first line.
possibly the easiest way is to split into an array then you can manipulate each element of the array as required
the text in each line must be enclosed in quotes
i believe the above example should have a space between the last & and the _ which is hidden by the html rendering of the page
or if more suitableCode:strData = Replace(strData, vbCrLf, " _" & vbCrLf & " & VbCrLf & ")
Code:strData = Replace(strData, vbCrLf, " & VbCrLf & _ " & vbCrLf )
I still get errors. Can you try your code with this example code?
<?php
if (!isset($page_title)) $page_title=""PHP code and online MySQL database - example username password"";
if (!isset($page_keywords)) $page_keywords=""free PHP code, mysql sql"";
if (!isset($page_desc)) $page_desc=""FREE example PHP code and a MySQL database"";
?>
<html>
<head>
<title><?php echo $page_title; ?></title>
<meta NAME=""keywords"" CONTENT=""<?php echo $page_keywords; ?>"">
<meta NAME=""description"" CONTENT=""<?php echo $page_desc; ?>"">
<meta NAME=""Content-Language"" CONTENT=""english"">
<meta name=""Revisit-after"" content=""56 days"">
<meta name=""Distribution"" content=""Global"">
<meta name=""Copyright"" content=""Copyright © 1996-2008 Seiretto.com"">
<meta NAME=""ROBOTS"" CONTENT=""ALL"">
<link rel=""stylesheet"" type=""text/css"" href=""tds.css"">
</head>
<body BACKGROUND=""DiscoverBack.gif""
style=""
SCROLLBAR-ARROW-COLOR: #BBCCFF;
SCROLLBAR-TRACK-COLOR: #C9DAF7;
SCROLLBAR-FACE-COLOR: #002163;""
TOPMARGIN=""0"" LEFTMARGIN=""15"" MARGINWIDTH=""0"" MARGINHEIGHT=""0"">
<div align=""center""><center>
<table border=""0"" width=""100%"" cellspacing=""0"" cellpadding=""0"">
<tr>
<td width=""100%""><p align=""center""><img height=""2"" src=""line.gif"" width=""99%"" border=""0""
alt=""PHP code examples with database connectivity""></td>
</tr>
<tr>
<td width=""100%""><img height=""2"" src=""line.gif"" width=""99%"" border=""0""
alt=""PHP code examples with database connectivity""><div align=""center""><center><table
border=""0"" width=""98%"" cellspacing=""0"" cellpadding=""0"">
<tr>
<td width=""9%""><font face=""Comic Sans MS""><strong><big> PHP.TheDemoSite.co.uk</big></strong></font></td>
<td><p align=""center""><small>Just examples of <b>PHP</b> code, linking to your <b>MySQL</b>
database and JavaScript.<br>
<a href=""index.php"">1. Home</a> | <a href=""thedatabase.php"">2. The Database</a> | <a
href=""addauser.php"">3. Add a User</a> | <a href=""login.php"">4. Login</a> | <a
href=""getyourowndbonline.php"">5. Get your db online</a></small></td>
</tr>
</table>
</center></div></td>
</tr>
<tr>
<td width=""100%""><p align=""center""><img height=""2"" src=""line.gif"" width=""99%"" border=""0""
alt=""PHP code examples with database connectivity""><br>
</td>
</tr>
</table>
</center></div>
<p align=""center""><i>Also, while here don't forget to have a look at <a href=""http://thedemosite.co.uk/phpformmailer/""><strong>phpFormMailer </strong>(easy to use PHP form mail - more secure than many cgi form mail</a>) </i></p>
<? include(""hostscripts-12870.inc"");?>
</table>
<table border=""0"" width=""100%"">
<tr>
<td>"
When i use
I get
helo" & vbCrLf & _this" & vbCrLf & _is" & vbCrLf & _a" & vbCrLf & _test" & vbCrLf & _
instead of
helo" & vbCrLf & _
this" & vbCrLf & _
is" & vbCrLf & _
etc
GAH.. i did it manually... 197 lines of code.
Sorry about that bud. Sometimes we get posters (usually with a low post count) that come in here with generalized questions like that having done nothing asking the group to do the work for them. Looks like you've gotten some assistance though ... so rock on!
-Max :D
for your future referenceQuote:
GAH.. i did it manually... 197 lines of code.
while it is easy to do what you wanted, you can not do it within the same project (or at least not easily)
the simple method is to start a new project with the following code, either in a commandbutton or sub main (no form required)
vb Code:
strdata = clipboard.gettext strData = Replace(strData, vbCrLf, """ & VbCrLf & _ " & vbCrLf & """") clipboard.clear clipboard.settext strdata
copy all the php code to clipboard, run the project, paste from clipboard to main project
note: there is a limitation on how many line continuations you can have, so you may get an error message "too many line continuations"
you can also open vb .frm files as text files, from vb, and edit the contents by code, but again you must follow vb's rules, you will get no error on writing the files, but may when reopening the file within the vb project