d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Could Use Some Vb Help
Prev123Next
Add Reply New Topic New Poll
Member
Posts: 21,222
Joined: Sep 10 2009
Gold: 0.00
May 7 2015 07:05pm
Quote (AbDuCt @ May 7 2015 09:02pm)
I don't know VB.

I don't even know if there is a print function.

Was just showing you how to loop backwards.


ye ty that makes sense lol ( you did help me figure out the loop tho so no worries)
Member
Posts: 21,222
Joined: Sep 10 2009
Gold: 0.00
May 7 2015 07:51pm
im failing to figure out how to use the loop to change words() and check against it :O any hints?


Function ispalindrome(sentence As String) As Boolean
Dim words() As String
Dim revwords() As String
Dim oldsentence As String
Dim revsentence As String
oldsentence = sentence
words = sentence.Replace(",", "").Split(" "c)
For i As Integer = words.Length To 0 Step -1
revwords(0) = words(i)
Next
revsentence = Join(revwords, " ")
If revsentence = oldsentence Then
Return True
Else
Return False
End If
End Function
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
May 7 2015 07:55pm
Quote (soullogik @ May 7 2015 09:51pm)
im failing to figure out how to use the loop to change words() and check against it :O any hints?


Function ispalindrome(sentence As String) As Boolean
Dim words() As String
Dim revwords() As String
Dim oldsentence As String
Dim revsentence As String
oldsentence = sentence
words = sentence.Replace(",", "").Split(" "c)
For i As Integer = words.Length To 0 Step -1
revwords(0) = words(i)
Next
revsentence = Join(revwords, " ")
If revsentence = oldsentence Then
Return True
Else
Return False
End If
End Function


what do you think you're doing there?
Member
Posts: 21,222
Joined: Sep 10 2009
Gold: 0.00
May 7 2015 07:57pm
Quote (carteblanche @ May 7 2015 09:55pm)
what do you think you're doing there?


ye thats where im stuck, it was really just me messing around trying to figure out how to assign words using the i to something. i know it doesnt work and thats sort of what im asking
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
May 7 2015 08:03pm
look into arrays.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
May 7 2015 08:55pm
if you need help with something VB specific lmk. I work with vb.net at work ~_~
Member
Posts: 21,222
Joined: Sep 10 2009
Gold: 0.00
May 7 2015 08:59pm
Quote (Eep @ May 7 2015 10:55pm)
if you need help with something VB specific lmk. I work with vb.net at work ~_~


im still stuck at the stuff i was talking about in my last post
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
May 7 2015 08:59pm
Quote (Eep @ May 7 2015 10:55pm)
if you need help with something VB specific lmk. I work with vb.net at work ~_~


Don't be fooled, he doesn't actually know how to do anything.

He only gets mad when we tell him to stop coding.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
May 7 2015 09:28pm
Quote (AbDuCt @ May 7 2015 09:59pm)
Don't be fooled, he doesn't actually know how to do anything.

He only gets mad when we tell him to stop coding.


Code
Sub Main()
Dim myString As String

myString = Console.ReadLine()

If Not myString = Nothing AndAlso Not String.Equals(myString, String.Empty, StringComparison.OrdinalIgnoreCase) Then
If String.Equals(myString, New String(myString.ToCharArray().Reverse().ToArray()), StringComparison.OrdinalIgnoreCase) Then
Console.WriteLine("PALINDROME!")
Console.ReadLine()
Else
Console.WriteLine("NOT PALINDROME!")
Console.ReadLine()
End If
End If
End Sub


I miss not having my usual extension methods

i just started intellisensing and wanted to see how far I could get

fuck that efficiency shit

This post was edited by Eep on May 7 2015 09:29pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
May 8 2015 05:35am
Quote (Eep @ May 7 2015 11:28pm)
Code
Sub Main()
Dim myString As String

myString = Console.ReadLine()

If Not myString = Nothing AndAlso Not String.Equals(myString, String.Empty, StringComparison.OrdinalIgnoreCase) Then
If String.Equals(myString, New String(myString.ToCharArray().Reverse().ToArray()), StringComparison.OrdinalIgnoreCase) Then
Console.WriteLine("PALINDROME!")
Console.ReadLine()
Else
Console.WriteLine("NOT PALINDROME!")
Console.ReadLine()
End If
End If
End Sub


I miss not having my usual extension methods

i just started intellisensing and wanted to see how far I could get

fuck that efficiency shit


one tiny problem. he's not checking for a palindrome of a string. he's checking if you reverse the order of words of a sentence.
Go Back To Programming & Development Topic List
Prev123Next
Add Reply New Topic New Poll