Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 9th, 2008, 01:59 PM
Registered User
 
Join Date: Feb 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need some help!!! How do I do this???

I need some help! I need some code in vb6 that will allow a user to input a word into the program. Then each character of the word will be compared to each letter of the alphabet and each occurrence will be counted. ex - dog is inputted it will have 1 occurrence of d and o and g. All other letters will be 0 occurrences. I will then display the results a scroolbox. results - a - 0, b - 0, c - 0, d - 1, etc.... I am thinking two arrays to somehow do this. Any ideas??

 
Old February 11th, 2008, 01:43 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

First of all, that is not much of a subject line. It is clear from the fact that you are posting a question in the first place that you need help with something. The purpose of the subject line is to attract people who have expertise in the area where you need help, without them having to read your question first.

Second, you stated unnecessarily in your subject line that you need help. So there's [u]reall</u>y no need to [u]re</u>state that in the body of your post...

I would loop through the entered word in a For loop:
Code:
    Dim i as Integer
    For i = 1 to Len(TheWord)
        ' then use Mid$(TheWord, i, 1) to access the character.
    Loop
    Characters have numeric value, their ASCII value. (For instance, “A” is ASCII 65.) If you are treating each character as only A through Z, convertng a through z to capital, you can dimension an array Dim TheArray(ASC("A") To ASC("Z")) As Integer, and increment the elements by testing the specific character's ASCII value with ASC(TheChar). If you are spanning the whole alphabet, both upper and lower case, You can make two arrays, and use an If statement in which if your char is between ASC("A") and ASC("Z") one part will be run that increments the right element in the UCase array, and the else part which is run if your char is between ASC("a") and ASC("z").
The incrementation can be
Code:
    MyArray(Asc(TheChar)) = MyArray(Asc(TheChar)) + 1
You could have just one array, which would have what is essentially a void area between ASC("Z") and ASC("A").
 
Old May 5th, 2012, 11:17 PM
Registered User
 
Join Date: Apr 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Query in Datagriview

Hi there,..I am new to vbnet 2008. I need a code sample to perform a query in my datagridview project, I am using access 2003. I have been trying several coding standards...and it doesn't work. To give you an idea of what I want, my project has several textboxes to show data from the grid. To perform the query, I am using a textbox and a search button to perform the query, but the code that I am using doesn't work...What Shall I do?
 
Old May 7th, 2012, 08:07 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Can you post your code snippet here.

Also ig would be good if you can post in on a VB.NET forum instead of Vb6

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips &amp; Tricks (http://www.vbadud.blogspot.com)









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.