|
First build a simple notepad which opens your html file and save with changes. Then add some patter matching[^] stuff.
--------------------------------
txtSignature
|
|
|
|
|
Hi,
If you need a simple Editor you could use a textbox control (MultiLine=True, Scrollbars=Both), for colored/advanced look, you could use the RichTextBox control, building an Intellisense Engine will require you extra effort, instead you could add a set of controls (menuitems/buttons) which allow users to click on them and select from a pop-up windows the type of tag/value to insert and here you can add some validation from your side. In addition You can use the WebBrowser control to add the feature of WYSIWYG, you could also host the Editor and Viewer (WebControl) on a TabControl. Also you could use the XHTML format and use the XML rules to validate the formatting (Well-fomatted XML Document)
Hope this helps
|
|
|
|
|
I am trying to update the Employees tbl in the northwind db. I want to use code behind to do it, to better understand databinding and how ds's and da's work. I am having an issue actually posting th edata back to the db.
I am using a detailsView to display the information on my page, I am also pulling the infor for the dv from a query string, here is my pageLoad code for my details page:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim connStr As String = ConfigurationManager.ConnectionStrings("NWConnectionString").ToString()
' Create DB Connection
Dim conn As New SqlConnection(connStr)
'Create DS
Dim ds As New DataSet
'Read EmployeeID from Default.aspx
Dim sEmployeeId As String = Request.QueryString("EmployeeID")
'Create DA
Dim da As New SqlDataAdapter("SELECT * FROM Employees WHERE [EmployeeID] = " & sEmployeeId, conn)
'Open Conn to DB
conn.Open()
'Fill DA with tbl
da.Fill(ds, "Employees")
'Set DataSource to DataSet
dvDetails.DataSource = ds
'Bind DV to ds
dvDetails.DataBind()
'Close DB Connection
conn.Close()
End If
End Sub
I will post the rest of the code in my next post, to keep the post a little shorter....
|
|
|
|
|
Here is the update logic that I have written:
Protected Sub update_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles update.Click
Dim connStr As String = ConfigurationManager.ConnectionStrings("NWConnectionString").ToString()
' Create DB Connection
Dim conn As New SqlConnection(connStr)
'Create Select Statement
Dim strSql As String = "Select * From Employees"
'Create Sql Update Statement
Dim upSql As String = "UPDATE Employees SET LastName=@LastName, FirstName=@FirstName, Title=@Title, Address=@Address," & _
"City=@City, Region=@Region, PostalCode=@PostalCode, HireDate=@HireDate Where EmployeeID=@EmployeeID"
Try
'Create DataAdapter
Dim da As New SqlDataAdapter
da.SelectCommand = New SqlCommand(strSql, conn)
'Create and Fill DataAdapter
Dim ds As New DataSet
da.Fill(ds, "Employees")
'Get the DataTable
Dim dt As DataTable = ds.Tables("Employees")
'Modify the Rows
dt.Rows(0)("LastName") = "@LastName"
dt.Rows(0)("FirstName") = "@FirstName"
dt.Rows(0)("Title") = "@Title"
dt.Rows(0)("Address") = "@Address"
dt.Rows(0)("City") = "@City"
dt.Rows(0)("Region") = "@Region"
dt.Rows(0)("PostalCode") = "@PostalCode"
dt.Rows(0)("HireDate") = "@HireDate"
'Update Employees Table
'Create Command
Dim upCmd As New SqlCommand(upSql, conn)
'Map Parameters
upCmd.Parameters.Add("@LastName", SqlDbType.VarChar, 20, "LastName")
upCmd.Parameters.Add("@FirstName", SqlDbType.VarChar, 10, "FirstName")
upCmd.Parameters.Add("@Title", SqlDbType.VarChar, 30, "Title")
upCmd.Parameters.Add("@Address", SqlDbType.VarChar, 60, "Address")
upCmd.Parameters.Add("@City", SqlDbType.VarChar, 15, "City")
upCmd.Parameters.Add("@Region", SqlDbType.VarChar, 15, "Region")
upCmd.Parameters.Add("@PostalCode", SqlDbType.VarChar, 10, "PostalCode")
upCmd.Parameters.Add("@HireDate", SqlDbType.DateTime, 8, "HireDate")
'Map EmployeeID Parameter
Dim idParam As SqlParameter = upCmd.Parameters.Add("@EmployeeID", SqlDbType.Int, 4, "EmployeeID")
idParam.SourceVersion = DataRowVersion.Original
'Open the connection
conn.Open()
'Update Employees Table
da.UpdateCommand = upCmd
ds.AcceptChanges()
da.Update(ds, "Employees")
Catch ex As Exception
'Display Error
Console.WriteLine("Error: " & ex.ToString())
Finally
'Close Connection
conn.Close()
'Redirect to Home
Response.Redirect("~/Default.aspx")
End Try
End Sub
I know it has something to do with passing the data back to the ds, but I am not sure what I am missing. Also, am I referencing an unknown row properly in the 'Modify Rows' section?
Any and all help is appreciated. I think I am close, but not sure what I am missing.
Stupid1
|
|
|
|
|
TextBox1.Text = Replace(SplitTextLineContent, SplitTextLineContent.Substring(SplitTextLineConten t.ToString().IndexOf("V"), SplitTextLineContent.ToString().IndexOf(vbNewLine) ), "")
SplitTextLineContent contains many lines of text.
I would like to replace those char or text that start with "V" until end of the line (vbNewLine) with " ". In other words, take out those text after "V" until the end of the line and replace with blank " ". But the coding above is incorrect. Pls help.
|
|
|
|
|
Hi,
first of all you will not win a special prize for trying to do all your stuff in a single
line of code; instead you will loose points for unintelligible code.
What you need is locate the start point of your string to be replaced (you have that already);
from there, find the next newline (use an overload of IndexOf that lets you specify a starting point);
then perform the necessary replacement, which requires two String.Substring calls (the
Replace method might "hit" several times!).
And you need to handle the special case when no newline is found too.
so in the end that will take about 5 lines of simple code.
|
|
|
|
|
Hi,
whether can show me the example? I don't understand
use an overload of IndexOf that lets you specify a starting point);
then perform the necessary replacement, which requires two String.Substring calls (the
Replace method might "hit" several times!
Your prompt reply will be kindly appreciated. Thanks
|
|
|
|
|
Hi,
this is what I meant in pseudo-code (I cant help it if it looks very much like C#);
myText is the string to be manipulated.
int startIndex=myText.IndexOf(theStringThatMarksTheBeginOfReplace);
if (startIndex>=0) {
int endMarkLen=theStringThatMarksTheEndOfReplace.Length;
int endIndex=myText.IndexOf(theStringThatMarksTheEndOfReplace, startIndex);
if (endIndex<0) myText=text.Substring(0,startIndex);
else myText=myText.Substring(0,startIndex)+myText.SubString(endIndex+endMarkLen);
}
That should do it. I suggest you read MSDN on any method you are unfamiliar with.
|
|
|
|
|
I got another question. If 1 line of text contain 2 "V", i would like to replace those char or text that start with second "V" until end of the line (vbNewLine) with " ". How to do it?
For substring(first_parameter, second_parameter), may i know what is the purpose of second_parameter?
|
|
|
|
|
If you want to find the second occurence, the easiest way is first find the first occurence,
if found, now look for the second (using the start parameter carefully, otherwise
you end up finding the first again); then if found, do what you intended to do.
A lot of methods have (or optionally have) both a start and a length, which means
do it from start up to start+length-1; so substring(start, length) copies part of
a string, with at most length chars copied, the ones in the range [start, start+length-1]
or less, if there arent that many.
You urgently need to get the habit of reading the documentation, either the
local copy of MSDN that comes with Visual Studio, or the MSDN web site that described
everything Microsoft has. Forums like these are not meant for duplicating the
Microsoft documentation.
|
|
|
|
|
If you want to find the second occurence, the easiest way is first find the first occurence,
if found, now look for the second (using the start parameter carefully, otherwise
you end up finding the first again); then if found, do what you intended to do.
A lot of methods have (or optionally have) both a start and a length, which means
do it from start up to start+length-1; so substring(start, length) copies part of
a string, with at most length chars copied, the ones in the range [start, start+length-1]
or less, if there arent that many.
You urgently need to get the habit of reading the documentation, either the
local copy of MSDN that comes with Visual Studio, or the MSDN web site that described
everything Microsoft has. Forums like these are not meant for duplicating the
Microsoft documentation.
And if you need a tutorial, I recommend you look for an introductory book on C#
in your local book shop or at Amazon's web site.
|
|
|
|
|
Dim textdelimiter As String<br />
textdelimiter = " "<br />
<br />
Dim splitout() = Split(TextLineContent, textdelimiter)<br />
<br />
Dim i As Integer<br />
<br />
For i = 0 To UBound(splitout)<br />
<br />
Dim startIndex As Integer<br />
startIndex = splitout(i).IndexOf("V")<br />
<br />
If startIndex >= 0 Then<br />
<br />
Dim endMarkLen = (splitout(i).Length)<br />
<br />
Dim endIndex = splitout(i).IndexOf(splitout(i), startIndex)<br />
<br />
Dim SecondstartIndex As Integer<br />
SecondstartIndex = splitout(i).IndexOf("V", startIndex)<br />
<br />
If (SecondstartIndex >= 0) Then<br />
splitout(i) = splitout(i).Substring(0, SecondstartIndex)<br />
Else<br />
If (endIndex < 0) Then<br />
<br />
splitout(i) = splitout(i).Substring(0, startIndex)<br />
<br />
Else<br />
splitout(i) = splitout(i).Substring(0, startIndex) + splitout(i).Substring(endIndex + endMarkLen)<br />
<br />
End If<br />
End If<br />
<br />
End If<br />
<br />
SplitTextLineContent += Trim(splitout(i)) & " " <br />
<br />
Next i
Hi,
It didn't work. i tried to find the second occurance of "V" and want to store the array from 0 to the second occurance of "V". I have already struggled for few hours.
|
|
|
|
|
Hi,
several comments:
1.
please use the PRE tag to show some code, it preserves indentation, makes things
much more readable on this forum
2.
why does your code contain a dozen splitout(i) ?
it would be much better to use a variable to hold this, say
Dim split As String
split=splitout(i)
this improves readability inside your IDE as well as on this forum
3.
first bug: endMarkLen must equal the length of the thing that marks the end of what you search,
so you can skip it; it could be 1 or 2 (for length of vbCrLf), it certainly is NOT equal
to split.Length
4.
second bug: you search in the wrong order, you must look for V, then for second V,
then for the end-of-line; there is no other way that is guaranteed to work.
Actually looking for a second V only adds 2 lines to the program you had before !
5.
if things dont work as intended, you must search the bugs, that is called debugging.
Lots of people will tell you to use a debugger for that; I tell you to (temporarily) add
some output statements to your code, showing the content of your variables at different
locations in your code.
It may seem like a bit of extra work, the advantage is you get the relevant information
one after another, listed sequentially (as opposed to a debugger that lets you peek into
just everything, but makes it more diffictult to see many things at once, especially
values before and after something has happened.
Hence add "log statements" and study the log; in this case, show startIndex, endIndex,
etc. and check them manually.
6.
And always true: if something does not work as intended, and it seems difficult to manage,
trim it to something smaller that still fails, but is easier to analyze; then debug,
find the mistake, learn from it, and go back to the bigger thing.
Good luck
|
|
|
|
|
Forgot to add: normally a Replace method (say String.Replace) replaces every occurence,
so "aha".Replace("a","o") yields "oho"
dont know what your Replace method does, if it replaces only one occurence, then maybe
you should choose a different name (ReplaceOnce ?).
|
|
|
|
|
Thanks. Problem solved.
|
|
|
|
|
i heve problem in implementation numerical method and matrix equation to create in visual basic
how to make inverse matrix 4x4 in visual basic code
give some example program and code
in another time i want show you my problem in example
I hope to get experince in programming visual basic and c++ and and i hope you want to discuse with me..
|
|
|
|
|
What problem? What error it says. We cannot help you without seeing your code.
SSK.
|
|
|
|
|
Vri SSK wrote: What problem?
I am guessing that he wants to make a 4x4 matrix and invert it...
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
|
I bet there are some pretty good articles buried in there. I will have to dig through since I do have a keen interest in matrices and linear algebra
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Yeah, as far as I can tell there are three main problems in the world:
- we have too many keen interests;
- there are a huge number of articles around;
- there are way too many people not searching but just asking.
|
|
|
|
|
Luc Pattyn wrote: we have too many keen interests
That's okay to an extent, but it can make things not very interesting sometimes.
Luc Pattyn wrote: there are a huge number of articles around;
Yes, and it does pose as a challenge weeding out the good from the bad. A favorite phrase from my Master's Thesis chairman, YAGNI (You Ain't Aren't Gonna Need It).
Luc Pattyn wrote: there are way too many people not searching but just asking
Yes, search first, can't find it, then ask
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Luc Pattyn wrote: we have too many keen interests;
Exactly, But the Peoples should think of it and use it.
Luc Pattyn wrote: there are a huge number of articles around;
Well Said, Because of the Pressure they are not able to read those articles.
Luc Pattyn wrote: there are way too many people not searching but just asking.
Exactly said Luc, before posting the code the guys should search it in google and after wards he could not find this means we can help you.
there are lot of peoples asking how to do without knowing the simple concepts.
That depends upon on his own interest only.
then only the programmer can sine in his life.
SSK.
|
|
|
|
|
How can i develop a traffic monitoring system. Please help me with the codes.
|
|
|
|
|
The best help I can give you (and the only help at this point) is to go some research on Google for what you're looking for, then start writing the application, then (and only then) if you run into problems come back here, give a description of the problem (along with the code thats causing the problem) then maybe someone will help you. To come here and say something like "help me with the codes" is going to get you ignored, we aren't here to do your work/homework assignments for you.
"Okay, I give up: which is NOT a real programming language????"
Michael Bergman
|
|
|
|
|