473,804 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.Net Looping Issues

36 New Member
I'm trying to take a word (stEAdy) and find the index positions of the uppercase characters(2,3) in the word. I have them stored in an array (positionarray) . Then I reverse the word and set all characters to lowercase. I've done that. Now, I want to take the reversed word (ydaets) and make the index positions from the array(2,3) uppercase for the reversed word, so that it will read (ydAEts). Below I'm looping thur the array incorrectly. I'm only able to get the first index position set. Any suggestions on setting up the loop correctly?

Thanks,
Wbosw

Expand|Select|Wrap|Line Numbers
  1.  'loop thur the position array, giving the position of the capital letters in each word
  2.             For Each Charposition As Byte In PositionArray
  3.  
  4.                 'set byte variable for For loop
  5.                 Dim j As Byte
  6.  
  7.                 'declare Char variable to hold the actual characters
  8.                 Dim char2 As Char
  9.  
  10.                 'set finalstring to nothing
  11.                 finalString = " "
  12.  
  13.                 'loop thur each word to see which positions are equal to the positions in the array
  14.                 For j = 0 To LowerRevText.Length - 1
  15.  
  16.                     char2 = LowerRevText.Chars(j)
  17.  
  18.                     'if the positions are equal then change the character to Uppercase
  19.                     If Charposition = j Then
  20.  
  21.                         'change the position to uppercase
  22.                         CapChar = Char.ToUpper(char2)
  23.  
  24.              'set char2 equal to CapChar
  25.                         char2 = CapChar
  26.  
  27.                     End If
  28.  
  29.                     CapRevText += char2
  30.  
  31.                 Next
  32.  
  33.                 'add a space between the words
  34.                 finalString += CapRevText + " "
  35.  
  36.                 'set variable = to nothing
  37.                 CapRevText = " "
  38.  
  39.             Next
Nov 9 '07 #1
4 1212
Plater
7,872 Recognized Expert Expert
I'm unclear on what situation you want to happen based on your example

Situation 1:
You want to make "tReE" be "eErT"


Situation 2:
You want to make "tReE" be "EeRt"


Situation 2 is just a reverse of the original string so I think you want situation 1.
if you have the positions in an int[] (that would be {0,3} for this example)
You would do something like this:
Expand|Select|Wrap|Line Numbers
  1. //ReverseLowerCase = original string reversed and converted to lowercase
  2. //ReverseUpperCase = original string reversed and converted to uppercase
  3. for(int i =0; i<myPosArray.Length;i++)
  4. {
  5.    ReverseLowerCase[i]= ReverseUpperCase[i];
  6. }
  7.  
You will need to make adjustments to fit vb
Nov 9 '07 #2
wbosw
36 New Member
My situation is like #1:

So I want to turn ( tReEGHp) into ( pHgEERt ) that would be positions 1,3,4,5.

would ReverseLowerCas e[i]= ReverseUpperCas e[i]; work in this situation, because it's on odd number of positions. if so, thanks in advance

Wbosw
Nov 9 '07 #3
Plater
7,872 Recognized Expert Expert
Say you had:
"TreEs"
Then ReverseLowerCas e ="seert"
and ReverseUpperCas e ="SEERT"
So if you knew you wanted index 0, 3

Then setting ReverseLowerCas e[0]=ReverseUpperCa se[0]
would make ReverseLowerCas e="Seert";
And setting ReverseLowerCas e[3]=ReverseUpperCa se[3]
would make ReverseLowerCas e="SeeRt";
Nov 9 '07 #4
wbosw
36 New Member
Thanks again Plater, you've been a great help.

Wbosw
Nov 9 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

45
7487
by: Trevor Best | last post by:
I did a test once using a looping variable, first dimmed as Integer, then as Long. I found the Integer was quicker at looping. I knew this to be true back in the 16 bit days where the CPU's (80286) word size was 16 bits same as an integer. Now with a 32 bit CPU I would have expected the long to be faster as it's the same size as the CPU's word size so wouldn't need sawing in half like a magician's assistant to calculate on like an...
5
2422
by: masood.iqbal | last post by:
My simplistic mind tells me that having local variables within looping constructs is a bad idea. The reason is that these variables are created during the beginning of an iteration and deleted at the end of the iteration. Kindly note that I am not talking about dynamically allocating memory within a loop, which is a perfectly valid operation (albeit with a chance of resulting in a memory leak, unless we are careful). The most common...
1
5391
by: Diva | last post by:
Hi, I have a data grid in my application. It has 20 rows and I have set the page size as 5. I have a Submit button on my form and when I click on Submit, I need to loop through the rows in the datagrid. Using the items collection just gives me the 5 rows that are displayed on the screen. Is there any way of looping through all the rows in the grid?
2
6352
by: randy1200 | last post by:
My hope is that somebody has a thought on this, or can point to toward an article that's useful. I have the following: DataSet ds = new DataSet(); ds.ReadXml("MyData.xml"); Each MainTable entry has subtable relations. Here's my current approach: foreach(DataRow row in ds.Tables.Rows {
4
1250
by: musosdev | last post by:
Hi I need to extend the contents of the src element of the <link relcss tags in the <headsection of my masterpage. From code, how can I access the <link elements within the <head? Cheers
0
1965
by: anthon | last post by:
Hi all - first post! anywho; I need to create a function for speeding up and down a looping clip. imagine a rotating object, triggered by an action, and slowly decreasing in speed, till it reaches a point 0 (compare a hand spinning a fortune wheel). now, this is quite an easy this to achieve, since you just have to set an interval to increase rotation, with a value that decreases over time (on every call), till it finally reaches a...
20
2856
by: Ifoel | last post by:
Hi all, Sorry im beginer in vb. I want making programm looping character or number. Just say i have numbers from 100 to 10000. just sample: Private Sub Timer1_Timer() if check1.value= 1 then
1
1294
by: gwenky | last post by:
Hello, so I was working this out yesterday and I am working on a function (w/o using arrays) that moves through the digits of a user inputted number and finds max/min ...this is the max option and it works ( up to < 10000), but I was wondering if there is a better format for looping this ...and if so where should I begin to look? int FindDigitAtPosition ( int x, double counter ) { for ( i = 1; i <= counter; ++i ) { if ( x < 10) {...
2
2084
by: Davaa | last post by:
Dear all, I am a student making a MS Form application in C++. I would ask a question about "Timer". Sample code which I am developing is below. private: System::Void buttonStart_Click(System::Object^ sender, System::EventArgs^ e){ for (int i=1; i<=10; i++){ String^ strValue; FunctionName(&strValue); int interval=1000; // time...
0
9712
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, 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...
0
10595
Oralloy
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...
0
10343
jinu1996
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...
1
7634
isladogs
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...
0
6862
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();...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
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
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
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...

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.