|
Actually there is a difference - at least it seems to me
ErrorMessage = "First Line" & vbCrLf & "second Line"
' This will produce a two line message
ErrorMessage = "First Line vbCrLf second Line"
' will not produce a two line message
(maybe replacing VBCrlf with something else would also work - but here is my solution so far)
LogMessage = "First Line \n second Line"
LogMessage = LogMessage.Replace("\n", Environment.NewLine)
MSGbox(Logmessage) ' will again produce a two line message
"First Line \n second Line"
is what get's stored as a resource - as you can see it will be easy to
change this into another language as you can add the line feeds wherever you need to.
In my code I also add Variables to the message - again this will allow for easy translation into another language.
A typical error message might look like this
" Error detected in line \VAR1 \n Dublicate \Var2 values detected!"
This might end up looking like this:
.....
Error detected in line 12
Dublicate N values detected!
....
|
|
|
|
|
I think that's a very good solution. I've used that system a lot. The only thing is that you may consider running the replace twice. First put the variables in place and then format the string with newlines. I sometimes have strings in variables that also contain \n. Doing this in two phases also replaces the newlines from variables correctly.
|
|
|
|
|
Hi,
if you want the multi-line string to be a single string in your database or your localized resource,
how about this:
- use a special substring to indicate NEWLINE (e.g. use \n like C/C++/Java/C# do)
- then replace it by actual newline at run-time; in VB.NET that would be
myString=myString.Replace("\n", Environment.NewLine)
I don't know how it would look in ancient VB.
- obviously reading the database/resource and replacing \n would fit nicely in a little method/function.
modified on Sunday, January 18, 2009 5:33 PM
|
|
|
|
|
Actually that's what I ended up doing last night ..
I was just "fishing" to see if there is a different way to do this
I ended up using @LF@ as the string to be replaced by the Environment.NewLine
I have to look int using \n instead - stick to the standard if possible ...
Anyway - thanks for taking the time to answer my question
As always "you guys" haven been great!
Georg
|
|
|
|
|
You're welcome.
|
|
|
|
|
Hi,
I am trying to use the Fill() method of dataAdapter class to fill a dataset but Im getting a SqlException error when I run my code. The error says Invalid object name 'Testing'. My database name is Runner.mdf and Testing is a table in my database. Heres my code. Hope someone can help. Thanks
Dim ds As New DataSet
Dim cn As New SqlConnection()
Dim connString As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents\Runner.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
cn.ConnectionString = connString
cn.Open()
Dim da As New SqlDataAdapter("SELECT * FROM Testing", cn)
da.Fill(ds)
|
|
|
|
|
carrigart wrote: SELECT * FROM Testing
Is this query executing successfully in query browser?
|
|
|
|
|
How do you use the query browser. Is that the same as the object browser.
I'm not familiar with both of them anyway
|
|
|
|
|
Yeah I figured out how to use the query browser and my query is working fine. It returns the contents of my database. Still getting the same error, so frustrating.
|
|
|
|
|
and one more thing, the code executes fine when I comment out the line da.Fill(ds), So is there something wrong with my dataset.
|
|
|
|
|
Do you have the database (runner.mdf) included in your project? If you do, select it from the project explorer and from properties, check two things:
- path to the file
- is Copy to output directory true
If copy to output directory is true, you should attach the database from the projects debug/bin folder, since each time you start the project the db is copied to that folder. Also note that in this case, all modifications done by program are not reflected to the original database, which is included to the project.
|
|
|
|
|
Yes the database is included in my project. I have checked the properties and the 'Copy to output directory' is set to 'Copy Always'. I'm not sure that I get you. Is it that the Path to the file should be the file in the debug/bin folder. So would I have to change and connection string and setup a new data source. Bit confused sorry
|
|
|
|
|
carrigart wrote: would I have to change and connection string and setup a new data source
Yes, exactly, you should modify the connection string and attach the mdf from your projects debug/bin folder. You don't have to create a new datasource, just modify the connection string.
carrigart wrote: Bit confused sorry
Nothing to be sorry about
|
|
|
|
|
Fixed it . Only took me like a day . I changed the path off my connection string. Bit of a school boy error . Well its a lesson learnt anyway.
Thanks for your help
|
|
|
|
|
You're welcome
|
|
|
|
|
This may sound daft, but have you tried it by populating a command and then setting the dataadapter.selectcommand to the command?
|
|
|
|
|
Hey gang I got a web browser that I am creating for a group that I belong to. The question is I have everything set up they way it should look. The only thing missing is the ability to block pop ups when debug before I make it a finale cut for distribution. This is my first attempt I got some help form a friend form a different forum but he is stumped as well. I hope some one can point me in to the right direction.
|
|
|
|
|
Hi!
Are you using the .NET webbrowser control? I ask because the features it provides are quite limited so implementing a pop-up blocker from it would be next to impossible. You may want to look into CSEXWB It provides a far richer set of features than the standard control and, though it's written in C#, can easily be added to your VB project.
Hope This Helps!
MrWolfy
|
|
|
|
|
Yes it is in .Net I see your point is there a tool kit that I can download? And if so could you send me the link?
|
|
|
|
|
Hi!
Sorry for the late reply. There was a link to CSEXWB in my last post, and with web browser controls being insanely complicated under the hood (Loads of C++ and stuff) they are very difficult to manipulate from VB.
This is basically why CSEXWB was created, it exposes several underlying events, methods and properties that you could not normally access from VB.
Hope This Helps!
MrWolfy
|
|
|
|
|
I have a windows form which has several controls like buttons, listviews, labels and a textbox.
Is there any generic way to always keep focus on that textbox?
|
|
|
|
|
Wow - let's see. You have buttons and listviews, and you never want any of them to get the focus ? how would that work ?
I guess you could catch keypresses and always respond by focusing on the textbox.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
What my point is here. As soon as other control's work is done, then the textbox should be focus.
I dont want to put textbox1.focus in every control's lostfocus event. I hope you understand me.
Thanks!
|
|
|
|
|
xbiplav wrote: As soon as other control's work is done, then the textbox should be focus.
Then set is back to being focused. Control.Focus() method[^]
|
|
|
|
|
I WANT VB.NET CODE FOR MAKING PROJECT ......
MY PROJECT IS CONECTIVITY OF MOBILE AND COMPUTER TO SEND SMS AND MAKE CALL WITH USE OF COMPUTER.....
SO GIVE ME ADVICE ..... AND ALSO SEND CODE FOR THIS PROJECT.....
THANKYOU...
|
|
|
|