Hi there,
Here is the line of VB code and I would like to translate into C#, please
help! Thanks!
sMsgIntHeader = (Replace(Replac e(Trim(Left(sEr rorMsg, InStr(5, sErrorMsg,
vbCrLf))), vbLf, ""), vbCr, "")) 2 13858
Wow.. that is pretty ugly.. I would try to make it easier to read in the
conversion to C# if I were you.
Here are some tips to get you started...
Take a look at the String class in .NET help. It contains all the helper
functions that you mentioned (Replace, Trim, Left, InStr, etc.) but they may
have a little different names.
In C# you can represent vbCr as "\r" and vbLf as "\n" so a replace may look
something like:
myStringVariabl e.Replace("\r", " ")
If there will always be a CR and LF at the end of your string then you could
do something like:
myStringVariabl e.Replace("\r\n ", " ")
Hope these help!
Chuck
"cloudx" <cl****@discuss ions.microsoft. com> wrote in message
news:79******** *************** ***********@mic rosoft.com... Hi there,
Here is the line of VB code and I would like to translate into C#, please help! Thanks!
sMsgIntHeader = (Replace(Replac e(Trim(Left(sEr rorMsg, InStr(5, sErrorMsg, vbCrLf))), vbLf, ""), vbCr, ""))
In message <79************ *************** *******@microso ft.com>, cloudx
<cl****@discuss ions.microsoft. com> writes Hi there,
Here is the line of VB code and I would like to translate into C#, please help! Thanks!
sMsgIntHeade r = (Replace(Replac e(Trim(Left(sEr rorMsg, InStr(5, sErrorMsg, vbCrLf))), vbLf, ""), vbCr, ""))
You could use something along the lines of
string s = "a,b,.c,d/e.f";
string [] t = s.Split('.',',' ,'/');
string u = string.Concat(t );
replacing '.', ',','/' with whatever characters you want to remove. Not
particularly fast or efficient, but if all you are doing is cleaning up
a short message, it doesn't really matter.
Or use the static System.Text.Reg ularExpressions .Regex.Replace method
using an appropriate pattern.
--
Steve Walker This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Johannes Busse |
last post by:
Hello,
I use saxon 6.5.3. under SuSE 9.1.
In my stylesheet I give out messages like
<xsl:message>
<xsl:value-of select="$myId" />
<xsl:text> | </xsl:text>
</xsl:message>
|
by: Jürgen Heyn |
last post by:
Good afternoon,
in a form a multiline textbox is defined:
<textarea name="text" cols="25" rows="3">This is the text.
this should be line 2</textarea>
In the textbox the linefeed is displayed correctly. Now I need to hand the
"value" property to a string variable like:
myString = document.forms.text.value;
In myString all linefeed commands have been deleted. Is it somehow possible
to keep the linefeed information ?
|
by: Reik |
last post by:
Hi,
in our application we use the following code snippet:
Dim target As String = Replace(txtLinkTarget.Text, "<SEP>", "'")
If target.StartsWith("(") AndAlso target.EndsWith(")") Then
In line 1 the text-value of of a textbox is retrieved. All occurences of
<SEP> are then replaced by an apostrophe.
However, if txtLinkTarget.Text returns an empty string, the Replace
|
by: Wade G. Pemberton |
last post by:
Help!:
I use javascript to format repetitive data from a web page input FORM
into a long string , and save it as lines of comma delimited data in a
text file on a Unix server. The text file is meant to be downloaded
to MS Excel on the users' computers. Several such files will be
downloaded and appended into the Excel file. Problem: The text file
looks good when viewed offline by any text reader, but Excel will not
import it...
|
by: Brian |
last post by:
I want to use regxp to check that a form input contains at least 1
non-space charcter. I'd like to only run this if the browser supports
it. For DOM stuff, I'd use
if (documentGetElementById) {}
Is there an object/feature detection I can use to check for regxp string
manipulation support?
--
| |
by: sck10 |
last post by:
Hello,
When I open a FormView in View mode, the line breaks are missing, but they
show up when I enter edit mode. So I tried to use the following on a
Textbox with a replace function, but got the following error:
Public member 'Replace' on type 'DBNull' not found.
<asp:Label ID="lblArchReviewItem"
Text='<%# Eval("ArchitectReview").Replace(vbcrlf,"<br />").Trim() %>'
|
by: Joe HM |
last post by:
Hello -
I have the following very simple code ...
Dim lStringA As String = ""
Dim lStringB As String = ""
....
lStringB = Replace(lStringA, "DUMMY", "", Compare:=CompareMethod.Text)
|
by: CK |
last post by:
Hi all,
I have a textarea control. I am putting it's value in an html email. The
problem is that the new lines are being ignored. I want to take the
controls value and replace any newline carriage returns, with an html <br>
tag. I tried the following function but it doesn't work. Does anyone have
any ideas how to accomplish this? Thanks in advance. ~ CK
string getComments()
|
by: Umesh |
last post by:
Do you have any answer to it? thx.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |