Does anyone know how to reverse a string using a loop? 3 10163
Hi,
first why doesn't
StrReverse( ) work for you?
for example:
TextBox1.Text = StrReverse(Text Box1.Text)
This is a loop that does the same as StrReverse
Dim strToReverse As String
strToReverse = TextBox1.Text
TextBox1.Text = ""
For i As Integer = strToReverse.Le ngth To 1 Step -1
TextBox1.Text &= Mid(strToRevers e, i, 1)
Next
hth Greetz Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.
"minguskhan " <mi********@dis cussions.micros oft.com> schreef in bericht
news:6F******** *************** ***********@mic rosoft.com... Does anyone know how to reverse a string using a loop?
Thanks for the reply. I know about that and yes it does work. I just heard
there was a way to do it using a loop and I am having trouble getting it to
work.
Regards,
minguskhan
"Peter Proost" wrote: Hi,
first why doesn't
StrReverse( ) work for you?
for example: TextBox1.Text = StrReverse(Text Box1.Text)
This is a loop that does the same as StrReverse
Dim strToReverse As String strToReverse = TextBox1.Text TextBox1.Text = "" For i As Integer = strToReverse.Le ngth To 1 Step -1 TextBox1.Text &= Mid(strToRevers e, i, 1) Next
hth Greetz Peter
-- Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"minguskhan " <mi********@dis cussions.micros oft.com> schreef in bericht news:6F******** *************** ***********@mic rosoft.com... Does anyone know how to reverse a string using a loop?
How about this?
'-----------------------------------------------------------------------
Option Strict
Imports System
public Class [class]
Public Shared Sub Main
Dim s As String = "Some randomly selected string to reverse"
Console.WriteLi ne(s)
Console.WriteLi ne(Reverse(s))
End SUb
Public Shared Function Reverse(s As String) As String
Dim c1() As Char = s.toCharArray
Dim offset As Integer = c1.length - 1
Dim c2(offset) As Char
For ndx As Integer = 0 To offset
c2(offset - ndx) = c1(ndx)
Next
Return New String(c2)
End Function
End Class
'-----------------------------------------------------------------------
"minguskhan " <mi********@dis cussions.micros oft.com> wrote in message
news:F6******** *************** ***********@mic rosoft.com...
: Thanks for the reply. I know about that and yes it does work. I just
heard
: there was a way to do it using a loop and I am having trouble getting
it to
: work.
:
: Regards,
:
: minguskhan
:
: "Peter Proost" wrote:
:
: > Hi,
: >
: > first why doesn't
: >
: > StrReverse( ) work for you?
: >
: > for example:
: > TextBox1.Text = StrReverse(Text Box1.Text)
: >
: > This is a loop that does the same as StrReverse
: >
: > Dim strToReverse As String
: > strToReverse = TextBox1.Text
: > TextBox1.Text = ""
: > For i As Integer = strToReverse.Le ngth To 1 Step -1
: > TextBox1.Text &= Mid(strToRevers e, i, 1)
: > Next
: >
: >
: > hth Greetz Peter
: >
: > --
: > Programming today is a race between software engineers striving to
build
: > bigger and better idiot-proof programs, and the Universe trying to
produce
: > bigger and better idiots. So far, the Universe is winning.
: >
: >
: > "minguskhan " <mi********@dis cussions.micros oft.com> schreef in
bericht
: > news:6F******** *************** ***********@mic rosoft.com...
: > > Does anyone know how to reverse a string using a loop?
: >
: >
: > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kevin |
last post by:
Hello,
I need to some help in reversing an 2-dimensional array. I am working
with gif images and I am trying to make the mirror image. I was
hoping that someone could help give me a headstart in how I can
accomplish this. Also, I don't know the the size of the array before
hand as the image can be any size. I already have the my read and
write gif functions working, but I just need to know how to reverse
the contents.
|
by: Tim Marshall |
last post by:
I use Terry Kreft's & Stephen Lebans colour dialog procedures for users
to pick colours for various control properties in certain apps.
Is there a way to take the colour code that is displayed in a
backcolor/forecolor/etc property and calculate the "reverse colour"? In
other words, If a user picks 255 (red) for a control backcolor, I'd like
to be able to calculate the opposite or negative of that colour and
assign the control's...
|
by: Albert |
last post by:
Why doesn't:
#include <stdio.h>
void reverse(char, int);
main()
{
char s;
|
by: dru |
last post by:
Problem:
Reversing the elements of an array involves swapping the corresponding elements of the array: the first with the last, the second with the next to the last, and so on, all the way to the middle of the array.
Given an array a , an int variable n containing the number of elements in a , and two other int variables, k and temp , write a loop that reverses the elements of the array.
Do not use any other variables besides ...
|
by: hello12 |
last post by:
Hello,
I am new to java and i was having a hard time figuring out on how to do certain string manipulations. I was asked to read in a text file and reverse the words. So far, I have put all the words in the text file into an arraylist.
For example...
Hello World. ---> must be printed out as --> olleH .dlroW
right now when i print my arraylist i am getting
I was thinking of somehow...
| |
by: arnuld |
last post by:
i have created a solutions myself. it compiles without any trouble
and runs but it prints some strange characters. i am not able to find
where is the trouble.
--------------------------------- PROGRAMME
--------------------------------
/* K&R2 section 1.9
exercise 1.19
|
by: Babikie |
last post by:
Write a program that performs a reverse recursion with following functions.
void swop (char,int,int);
void reverse (char);
void rev(char,int, int);
User should enter a string and all character should be reversed. Note! The
rev function should be used as the recursive function, accepting the string, plus
the first and last position of string. The reverse() passes the first and the last
position of the string to the rev() which performs the...
|
by: Scott |
last post by:
Yeah I know strings == immutable, but question 1 in section 7.14 of "How to
think like a computer Scientist" has me trying to reverse one.
I've come up with two things, one works almost like it should except that
every traversal thru the string I've gotten it to repeat the "list" again.
This is what it looks like:
for char in x:
mylist.append(char)
|
by: rajkumarbathula |
last post by:
Hi
Could any one help me out in reversing rows/elements of DataTable or String or DataList by using any simple statement?
Thanks
|
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: 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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |