Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-02-2006, 06:24 PM   #1 (permalink)
deehanie
Registered User
 
Join Date: Mar 2006
Posts: 2
deehanie is on a distinguished road
plez help!counting letters in string

i tried this but it says error in ' If MyArray(i) = "a" ', that it was out of array bound. did i missing something?

Function MyLetter()
Dim aCount As Integer = 0
Dim bCount As Integer = 0
Dim cCount As Integer = 0
'letter = window.prompt('Please enter a letter', '');
'length = letter.length;
'var my_array = letter.split("");
Dim MyString = txtLetter.Text.Length
Dim MyArray = "aabbcc"

Dim i As Integer
For i = 0 To MyString - 1 Step i + 1


If MyArray(i) = "a" Then
aCount = aCount + 1
ElseIf MyArray(i) = "b" Then

bCount = bCount + 1

ElseIf MyArray(i) = "c" Then
cCount = cCount + 1

End If
Next
Label1.Text = aCount
End Function
deehanie is offline   Reply With Quote
Old 03-02-2006, 09:42 PM   #2 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
should ' For i = 0 To MyString - 1 Step i + 1' be ' For i = 0 To MyArray.length - 1 Step i + 1' ?
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 03-03-2006, 04:44 AM   #3 (permalink)
deehanie
Registered User
 
Join Date: Mar 2006
Posts: 2
deehanie is on a distinguished road
okay, finally i get to do that counting letter.I'm using aschii value in vb.But what if i want to count letter from specific input text file? Is there any way to do it?To read the file is no problem..but to count letter and give result of the letter occurrence? can u help with this?tq~
deehanie is offline   Reply With Quote
Old 03-22-2006, 06:57 PM   #4 (permalink)
rdove
Masked Moderator
 
rdove's Avatar
 
Join Date: May 2002
Location: Indianapolis, IN
Posts: 260
rdove is on a distinguished road
So are you storing the letter or letters you want to count in a text file or are you wanting to create a count of all the individual letters in the text file?
__________________
~Ryan

rdove is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help for another program Androto Standard C, C++ 54 10-15-2004 07:21 AM
sorting objects arrays by object properties sde Java 28 08-05-2004 05:51 AM
From C to Java HighterDK Java 11 07-13-2004 07:15 PM


All times are GMT -8. The time now is 05:05 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting