Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
String Pattern : Alternet Character Capital
#1
Solved: 8 Years, 6 Months, 3 Weeks ago
Hi, I need help from you guys.

Input String: abhijit abhijit
O/p String: aBhIjIt AbHiJiT

I need a script to get alternate character Capital. Big Grin
Reply
#2
Solved: 8 Years, 6 Months, 3 Weeks ago
Quick Snippet
Code:
input = "abhijit abhijit"
For i  = 1 To len(input) Step 1
    If  i mod 2 = 0 Then
        outPut = output & Ucase(Mid(input,i,1))
    Else
        outPut = output & Mid(input,i,1)
    End If
    
Next

msgbox output
Thanks,
SUpputuri
Reply
#3
Solved: 8 Years, 6 Months, 3 Weeks ago
Thanks for Reply. But this code is not handling space. It should not consider space and should make next character Capital/Small

Input: a a a a
O/p: a A a A
Reply
#4
Solved: 8 Years, 6 Months, 3 Weeks ago
here is the updated code.
Code:
input = "abhijit abhijit"
charCounter = 1
For i  = 1 To len(input) Step 1

    char = Mid(input,i,1)
    If char <> " " Then
        If  charCounter mod 2 = 0 Then
            outPut = output & Ucase(char)
    Else
            outPut = output & lcase(char)
    End If
        charCounter = charCounter + 1
    else
    output = output & char
    End If
Next

msgbox output
Note:- I have done it based on the pure requirement in this query. Ideally we have to check if the value is an alphabet and then change the case.
Thanks,
SUpputuri
Reply
#5
Solved: 8 Years, 6 Months, 3 Weeks ago
Thanks a Ton Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Not able to use wild character in string amit25007 2 2,379 03-09-2016, 10:36 AM
Last Post: amit25007
  VB Script:number of times a character appears in a string with position Jyobtech 1 11,678 08-07-2013, 01:03 PM
Last Post: anil2u
  Find capital letter in a string Arul 2 8,318 12-27-2011, 11:11 PM
Last Post: Arul
  How to have a variable that has a string comma string .. shareq1310 5 4,757 11-09-2011, 03:33 PM
Last Post: parminderdhiman84
Question String Comparison using escape character Charanpreet 2 3,865 04-21-2011, 07:12 PM
Last Post: sreekanth chilam

Forum Jump:


Users browsing this thread: 1 Guest(s)