473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

String String Function

All the String functions like 'Len', 'Left', 'Right', 'Mid' etc. that
are available in ASP are supported by ASP.NET as well except for the
string function 'String'.

The 'String' function takes this form:

String(number, character)

which returns a string consisting of *character* which is repeated
*number* times. For e.g.

String(3, "$")

would return

$$$

or

String(5, "A")

would return

AAAAA

But when I try to use this function in ASP.NET, the following error
gets generated

'String' is a class type and cannot be used as an expression.

It's pretty obvious what makes ASP.NET generate the above error but
how do I make use of this 'String' function in ASP.NET? Is there any
equivalent string function in ASP.NET?

Actually my main intention is to replace the first 10 characters of a
text with dots irrespective of the no. of characters in the text (or
the 'Len' of the text) which is why I needed to use the 'String'
function. Had ASP.NET supported the 'String' function, then the
following would have served my purpose:

strText = "The quick brown fox jumps over the lazy dog."
strText = String(10, ".") & Mid(strText, 11, Len(strText))

I can't use the 'Replace' function since the first 10 characters (or,
for that matter, the entire text) can be a combination any characters
(even non-alphanumeric).

Feb 7 '07 #1
2 10269
string str = new string(' ', 10);

<rn**@rediffmail.comwrote in message
news:11**********************@k78g2000cwa.googlegr oups.com...
All the String functions like 'Len', 'Left', 'Right', 'Mid' etc. that
are available in ASP are supported by ASP.NET as well except for the
string function 'String'.

The 'String' function takes this form:

String(number, character)

which returns a string consisting of *character* which is repeated
*number* times. For e.g.

String(3, "$")

would return

$$$

or

String(5, "A")

would return

AAAAA

But when I try to use this function in ASP.NET, the following error
gets generated

'String' is a class type and cannot be used as an expression.

It's pretty obvious what makes ASP.NET generate the above error but
how do I make use of this 'String' function in ASP.NET? Is there any
equivalent string function in ASP.NET?

Actually my main intention is to replace the first 10 characters of a
text with dots irrespective of the no. of characters in the text (or
the 'Len' of the text) which is why I needed to use the 'String'
function. Had ASP.NET supported the 'String' function, then the
following would have served my purpose:

strText = "The quick brown fox jumps over the lazy dog."
strText = String(10, ".") & Mid(strText, 11, Len(strText))

I can't use the 'Replace' function since the first 10 characters (or,
for that matter, the entire text) can be a combination any characters
(even non-alphanumeric).

Feb 7 '07 #2
On Feb 7, 9:17 pm, "Aidy" <a...@noemail.xxxa.comwrote:
string str = new string(' ', 10);

<r...@rediffmail.comwrote in message

news:11**********************@k78g2000cwa.googlegr oups.com...
All the String functions like 'Len', 'Left', 'Right', 'Mid' etc. that
are available in ASP are supported by ASP.NET as well except for the
string function 'String'.
The 'String' function takes this form:
String(number, character)
which returns a string consisting of *character* which is repeated
*number* times. For e.g.
String(3, "$")
would return
$$$
or
String(5, "A")
would return
AAAAA
But when I try to use this function in ASP.NET, the following error
gets generated
'String' is a class type and cannot be used as an expression.
It's pretty obvious what makes ASP.NET generate the above error but
how do I make use of this 'String' function in ASP.NET? Is there any
equivalent string function in ASP.NET?
Actually my main intention is to replace the first 10 characters of a
text with dots irrespective of the no. of characters in the text (or
the 'Len' of the text) which is why I needed to use the 'String'
function. Had ASP.NET supported the 'String' function, then the
following would have served my purpose:
strText = "The quick brown fox jumps over the lazy dog."
strText = String(10, ".") & Mid(strText, 11, Len(strText))
I can't use the 'Replace' function since the first 10 characters (or,
for that matter, the entire text) can be a combination any characters
(even non-alphanumeric).- Hide quoted text -

- Show quoted text -
Thanks a lot, Aidy :-)

Feb 7 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people...
9
by: Danny | last post by:
HI again Is there a nifty function in access that will: 1. return the amount of occurances of a small string within a larger string? this<br>is<br>a<br>test would return 3 for <br>
4
by: songkv | last post by:
Hi, I am trying to reassign an array of char to a string literal by calling a function. In the function I use pointer-to-pointer since I want to reassign the "string array pointer" to the string...
4
by: Simon Schaap | last post by:
Hello, I have encountered a strange problem and I hope you can help me to understand it. What I want to do is to pass an array of chars to a function that will split it up (on every location where...
18
by: intercom5 | last post by:
I'm writing a program in C, and thus have to use C strings. The problem that I am having is I don't know how to reallocate the space for a C string outside the scope of that string. For example:...
35
by: Cor | last post by:
Hallo, I have promised Jay B yesterday to do some tests. The subject was a string evaluation that Jon had send in. Jay B was in doubt what was better because there was a discussion in the C#...
5
by: Sia Jai Sung | last post by:
Hi, I have a class that I modify from a sample program, like below ========================================== Imports System Imports System.Web.UI Imports System.Security.Cryptography ...
9
by: rsine | last post by:
I have developed a program that sends a command through the serial port to our business system and then reads from the buffer looking for a number. Everything worked great on my WinXP system, but...
17
by: Tom | last post by:
Is there such a thing as a CONTAINS for a string variable in VB.NET? For instance, I want to do something like the following: If strTest Contains ("A","B", "C") Then Debug.WriteLine("Found...
11
by: Darren Anderson | last post by:
I have a function that I've tried using in an if then statement and I've found that no matter how much reworking I do with the code, the expected result is incorrect. the code: If Not...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.