473,395 Members | 1,783 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,395 software developers and data experts.

Alternating toUpper

Hi there,

I'm trying to create a function to make alternating uppercase and lowercase letters of a string using loops. e.g: funny = FuNnY or judge = JuDge

Dim a As String = TextBox9.Text
Dim b As String
Dim d As String
For i As Integer = 0 To a.Length - 1 Step 2
Dim c As String = a(i)
b = b & d & c.ToUpper
For o As Integer = 1 To a.Length - 1 Step 2
Dim f As String = a(o)
d = d & f.ToLower
Next
Next
TextBox9.Text = b

(in a private sub for a button click)

unfortunately this only works for 3 letter words... I'm stuck.. any advice is MUCH appreciated!!

thanks!
Oct 20 '08 #1
2 1301
Are you really sure the code you posted worked?
Expand|Select|Wrap|Line Numbers
  1. Function NotFunny(ByRef strText As String) As String
  2.  On Error GoTo HandleError
  3.  Dim n As Long
  4.  Dim lngDivisor As Long
  5.  Dim strTemp As String
  6.  strTemp = strText
  7.  lngDivisor = 2
  8.  
  9.  For n = 1 To Len(strTemp)
  10.   If n Mod lngDivisor <> 0 Then
  11.      Mid$(strTemp, n, 1) = UCase(Mid$(strTemp, n, 1))
  12.   Else
  13.      Mid$(strTemp, n, 1) = LCase(Mid$(strTemp, n, 1))
  14.   End If
  15.  Next
  16.  
  17.  NotFunny = strTemp
  18.  Exit Function
  19. HandleError:
  20.  MsgBox "There is no hope."
  21. End Function
Oct 20 '08 #2
QVeen72
1,445 Expert 1GB
Hi,

Try This :

Expand|Select|Wrap|Line Numbers
  1. Dim a As String = TextBox9.Text
  2. Dim b As String = ""
  3. For i As Integer = 0 To a.Length - 1
  4.     If i Mod 2 = 0 Then
  5.         b = b & a.SubString(i,1).ToUpper
  6.     Else
  7.         b = b & a.SubString(i,1).ToLower
  8.     End If
  9. Next
  10. TextBox9.Text = b
  11.  
Regards
Veena
Oct 21 '08 #3

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

Similar topics

18
by: didgerman | last post by:
Chaps, I need to properly format the case of a struct. Can I just hit it with tolower, and then 'while (string ==' ') pos++; string=toupper(string); to add in the higher case for the start of...
0
by: Shrinivas Reddy | last post by:
Hi, I am using the ToUpper() function in an FXCop rule which checks whether a boolean variable has "is" or "has" as the prefix. The ToUpper() function does not work. When I put the expression...
1
by: Eirik Eldorsen | last post by:
I'm trying to set alternating bgcolor for a datalist with 2 columns. My problem is that its the alternating cell that get the bgcolor, not the row. Is it possible to set alternating color of rows?...
9
by: Max Weebler | last post by:
Hi, I have a datagrid built that has an alternating item style that sets the backcolor and ForeColor of its rows. I have 4 template columns. One of them has a LinkButton embedded in it to...
48
by: Frederick Gotham | last post by:
The "toupper" function takes an int as an argument. That's not too irrational given that a character literal is of type "int" in C. (Although why it isn't of type "char" escapes me... ) The...
4
by: sandy | last post by:
I am trying to upper case a string, so I have this method: string FileSystem::toupper(string S) { for (int i=0; i<S.length(); ++i) { S=toupper(S); } return S;
3
by: Daniel Manes | last post by:
My DataGridView is set up like this: * Main row background color = white * Alternating row background color = light gray I also have a read-only (non-editable) column I want to show up as solid...
4
by: mike | last post by:
how can I change the font color for an alternating row where the column data is formatted as a link? setting a style in the stylesheet for a { color:white; }
16
by: gaga | last post by:
my function should accept a pointer to a string as its argument. and it should convert each charater to an uppercase letter. I know what i need to do, its just my syntax is all out of whack. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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,...
0
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...
0
tracyyun
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...

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.