Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 15th, 2007, 10:22 AM
Triple H Triple H is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 4 Triple H User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 m 17 sec
Reputation Power: 0
Newbie needs help

ok, here is my problem, I am in a grade 12 programming class and I am stuck on something so simple its stupid but my problem is that I just cant wrap my mind around it. Here is the program I have to make:

The user must input a sentence and the program must check and see if the sentence is the same backwards and fowards. for example: I am therefore am I <---- that is the same back and forth

I am stuck here, I would really appreachate it if I got some help on this. I just want to understand this stuff.

All Help would be really appreachated Thanks

Reply With Quote
  #2  
Old February 15th, 2007, 09:49 PM
Alias-Zero Alias-Zero is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Location: localhost
Posts: 40 Alias-Zero User rank is Lance Corporal (50 - 100 Reputation Level)Alias-Zero User rank is Lance Corporal (50 - 100 Reputation Level)Alias-Zero User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 14 h 44 m 12 sec
Reputation Power: 4
Send a message via ICQ to Alias-Zero Send a message via AIM to Alias-Zero Send a message via MSN to Alias-Zero Send a message via Yahoo to Alias-Zero
Quote:
Originally Posted by Triple H
ok, here is my problem, I am in a grade 12 programming class and I am stuck on something so simple its stupid but my problem is that I just cant wrap my mind around it. Here is the program I have to make:

The user must input a sentence and the program must check and see if the sentence is the same backwards and fowards. for example: I am therefore am I <---- that is the same back and forth

I am stuck here, I would really appreachate it if I got some help on this. I just want to understand this stuff.

All Help would be really appreachated Thanks


Wow, not entirely sure what you're looking for, I was thinking palindrome originally,but it seems not. I'll explain both.

Not entirely sure what your teacher is looking for, and in no way am I going to do your homework for you. But I will explain a way to do it.


The Palindrome
Ex: racecar reversed is the same word, racecar

You could use a textbox for your user input, and from that loop through backwards (or forwards if you wanted, but it's less confusing backwards) and make a new string of the reversed characters and compare them with if x1 = x2.

Pseudo:

user input
for loop from len x to 1, with a step of -1
newstring = newstring + place of userinput with the loop iteration
next
if user input = newstring
win
else
lose

--------------------------------------------------

What you seem to be saying
Ex: I am therefore am I

You could use a textbox for user input, seperate with words delimiting by spaces, loop through backwards and make a new string with the words reversed, then use if x1 = x2, when rearranging the words, make sure to readd the spaces, and make sure you don't add a space on the last word of the loop.

Pseudo:

user input
delimit by space, get an array
for loop to upper of the array, to lower of array, step -1
check to see if you're at the lower of the loop
if yes new string = new string + word(step)
if no new string = newstring + word(step) + space
next
if user input = new string
win
else
lose

Reply With Quote
  #3  
Old February 16th, 2007, 03:25 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 1,932 sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 6 Days 22 h 36 m 35 sec
Reputation Power: 1243
Like Alias-Zero, I dont like writing your homework for you but your question got my attention and I wanted to find a slick way of doing it. Alias-Zero's logic is spot on, but I wanted to demonstrate a slightly different approach which doesn't involve concatenating the strings, instead, use Split make the string into an array (you can specify what character to use as the delimiter when using split eg. Split(astring, "|") but it defaults to a space!!), then compare the first element of the array with the last, the second with the second last etc...:
Code:
Dim a, b As Integer
Dim strArray() As String
Dim isOK As Boolean          

Private Sub Command1_Click()
     strArray = Split(Text1.Text)
     b = UBound(strArray)
     isOK = True
     For a = 0 To UBound(strArray)
         If Trim(UCase(strArray(a))) <> Trim(UCase(strArray(b))) Then isOK = False
         b = b - 1
     Next
     If isOK Then
          MsgBox "ok"
     Else
          MsgBox "incorrect"
     End If
End Sub

Reply With Quote
  #4  
Old February 16th, 2007, 10:04 AM
Triple H Triple H is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 4 Triple H User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 m 17 sec
Reputation Power: 0
thank you guys I dont like homework being done for me either I like to learn things on my own thank you guys for all your help here

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Newbie needs help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT