Sinisterly
Help with the code - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Visual Basic & .NET Framework (https://sinister.li/Forum-Visual-Basic-NET-Framework)
+--- Thread: Help with the code (/Thread-Help-with-the-code)

Pages: 1 2


Help with the code - zibi860810 - 02-12-2014

Hi, i found this thread on this forum LINK, I wanted to use it to my program, i copy and paste it for test. It's good but when i copy url with http://
i have this error[Image: ivdw.jpg] I translate the error because it is in polish
"cannot convert prompt argument to string type". Can anyone help me with this error? Please be patient, i'm begginnerSmile


RE: Help with the code - Deque - 02-12-2014

The MsgBox needs a string. So you can't give it an Exception, because that's not a string. You probably want to get the message string of the Exception first.


RE: Help with the code - zibi860810 - 02-12-2014

Ok, can you help me with fix that problem, i'm only begginerSmile I make this with the code and now i have a different error [Image: iapw.jpg]


RE: Help with the code - Ligeti - 02-12-2014

shouldn't it be ex.message?

[edit] I think Nieznany mean "Unknown"
Do you want me to explain the whole exception message?

[edit] Sorry I thought you were asking for the translation (I didn't see it), apologies!

Try ex.message first, and ... try this:

Code:
if TextBox1.Text.Contains("http://") Then Dim entry As String = TextBox1.Text.Replace("http://", "").Trim() Dim iphe As IPHostEntry = Dns.GetHostEntry(entry) ...



RE: Help with the code - zibi860810 - 02-12-2014

Thanks Ligeti, your answer is very helpful. Now my code lokking like this
Code:
Imports System.Net Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try If TextBox1.Text.Contains("http://") Then Dim iphe As IPHostEntry = Dns.GetHostEntry(TextBox1.Text.Replace("http://", "").Trim()) TextBox2.Text = iphe.AddressList(0).ToString() ElseIf TextBox1.Text.Contains("https://") Then Dim iphe As IPHostEntry = Dns.GetHostEntry(TextBox1.Text.Replace("https://", "").Trim()) TextBox2.Text = iphe.AddressList(0).ToString() Else Dim iphe As IPHostEntry = Dns.GetHostEntry(TextBox1.Text) TextBox2.Text = iphe.AddressList(0).ToString() End If Catch ex As Exception MsgBox(ex.Message) End Try End Sub End Class

And it's good. Maybe notSad One little problem, if i paste URL like this https://www.something.com there is ok but like this http://www.something.com/ it's not ok. This "/" is the problem, how can i add '/' to list of exceptions. I tried like this [Image: pp48.jpg]:) and that's not working


RE: Help with the code - Ligeti - 02-12-2014

You're welcome :-)

use regular expression, that will solve all you problems!


RE: Help with the code - zibi860810 - 02-12-2014

OkSmile Thanks for help. Can you recommend me some tutorials of vb.net for totally beginners??


RE: Help with the code - Ligeti - 02-12-2014

Of course, first try: http://www.hackcommunity.com/Forum-Visual-Basic-and-NET-Framework-Family there are some very good VB threads there!

I personally don't program in VB, in fact this i maybe the second time in my life that I write a code in VB lol, I know C# ... but I am a Linux guy.

You can also try:
http://www.dotnetperls.com/vb, I like the design of that website! And it has some great topics about .NET

And as for Regular Expression I highly recommend that you use Expresso: http://www.ultrapico.com/expresso.htm, it is a great tool to test regular expressions.

Happy coding and good luck Smile


RE: Help with the code - zibi860810 - 02-12-2014

Thank you very muchSmileOoooo, the link to ultrapico is not working, dotnetperls tooSad


RE: Help with the code - chmod - 02-14-2014

(02-12-2014, 07:12 PM)zibi860810 Wrote: Thank you very muchSmileOoooo, the link to ultrapico is not working, dotnetperls tooSad

It's because the comma (,) got included with the url just remove it from the address bar and try again