EvilZone

Programming and Scripting => .NET Framework => : gh0st April 17, 2011, 02:07:37 AM

: [VB2010] if,else,then,i/o problem
: gh0st April 17, 2011, 02:07:37 AM
guys Ive just started to learn VB and Ive coded this:

:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Dim input As System.Char = input
    End Sub

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
        If InputBox() Is hello Then
            Console.WriteLine("hello")
        ElseIf Input() Is bye Then
            Console.WriteLine("bybye")
        Else : Console.WriteLine("Im not completed yet")
    End Sub
End Class

I get like 5 errors:
:
Error 1 Argument not specified for parameter 'Prompt' of 'Public Function InputBox(Prompt As String, [Title As String = ""], [DefaultResponse As String = ""], [XPos As Integer = -1], [YPos As Integer = -1]) As String'. C:\Users\Fernando\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 12 12 WindowsApplication1
Error 2 'hello' is not declared. It may be inaccessible due to its protection level. C:\Users\Fernando\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 12 26 WindowsApplication1
Error 3 Overload resolution failed because no accessible 'Input' accepts this number of arguments. C:\Users\Fernando\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 14 16 WindowsApplication1
Error 4 'bye' is not declared. It may be inaccessible due to its protection level. C:\Users\Fernando\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 14 27 WindowsApplication1
Error 5 'If' must end with a matching 'End If'. C:\Users\Fernando\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 16 9 WindowsApplication1

well basicly I want the program to ask for an input in the first textbox and then make the output on the textbox2 plz someone help me in my first program  :-\

http://postimage.org/image/1fhzp4tk4/ (http://postimage.org/image/1fhzp4tk4/)
: Re: [VB2010] if,else,then,i/o problem
: Zesh April 17, 2011, 02:14:25 AM
Damn I hate .NET with all its sender As System.Object :P Anywayz this should fix your problems

:
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
        If InputBox() Is "hello" Then
            Console.WriteLine("hello")
        ElseIf Input() Is "bye" Then
            Console.WriteLine("bybye")
        Else : Console.WriteLine("Im not completed yet")
        End If
    End Sub

Edit: The fisrt code may still give you errors but you can do it like this

:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim tInput As String

tInput = InputBox("Enter text below!")

If tInput = "hello" Then
Console.WriteLine ("hello")

ElseIf tInput = "bye" Then
Console.WriteLine ("bybye")

Else: Console.WriteLine ("Im not completed yet")
End If
End Sub
: Re: [VB2010] if,else,then,i/o problem
: ande April 17, 2011, 04:11:17 AM
Damn I hate .NET with all its sender As System.Object :P Anywayz this should fix your problems

Those are not requited but added by visual studio to make things easier for you. With the sender object you can see what object triggered the code. Lets say you have 10 buttons and all of them point to the same method, with the sender object you could still distinguish them. The e object contains info etc regarding the methods task. Lets say you have a webbrowser control, on its OnNavigate method you can change e.cancel to true or false if you want to cancel the navigation before it happens.
: Re: [VB2010] if,else,then,i/o problem
: 10n1z3d April 17, 2011, 09:58:23 AM
Friendly advice: Leave VB.NET and start C# before it's too late.
: Re: [VB2010] if,else,then,i/o problem
: Stackprotector April 18, 2011, 12:58:27 AM
Friendly advice: Leave VB.NET and start C# before it's too late.
I totally agree, or continue with c++.
VB isnt as great as it seems just because its easy.
However, it will get the job done for some basic projects.
: Re: [VB2010] if,else,then,i/o problem
: 10n1z3d April 18, 2011, 11:26:21 AM
: The New Hacker's Dictionary
BASIC /bay'-sic/ n.
A programming language, originally designed for Dartmouth's experimental timesharing system in the early 1960s, which for many years was the leading cause of brain damage in proto-hackers. Edsger W. Dijkstra observed in "Selected Writings on Computing: A Personal Perspective" that "It is practically impossible to each good programming style to students that have had prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration." This is another case (like Pascal) of the cascading lossage that happens when a language deliberately designed as an educational toy gets taken too seriously. A novice can write short BASIC programs (on the order of 10-20 lines) very easily; writing anything longer (a) is very painful, and (b) encourages bad habits that will make it harder to use more powerful languages well. This wouldn't be so bad if historical accidents hadn't made BASIC so common on low-end micros in the 1980s. As it is, it probably ruined tens of thousands of potential wizards.

That's the definition of BASIC in The New Hacker's Dictionary which I strongly agree.
: Re: [VB2010] if,else,then,i/o problem
: gh0st April 19, 2011, 04:56:16 PM
I got the answer thanx btw
: Re: [VB2010] if,else,then,i/o problem
: Xires April 19, 2011, 05:05:57 PM
gh0st; why did you go from C++ to VB.NET?  You've barely scratched the surface on C++ and now you're going to an inferior language?
: Re: [VB2010] if,else,then,i/o problem
: gh0st April 19, 2011, 08:11:51 PM
I highly find VB more didactic than any language till that point that Im going to buy two books in amazon in this week
: Re: [VB2010] if,else,then,i/o problem
: Stackprotector April 19, 2011, 11:48:32 PM
I highly find VB more didactic than any language till that point that I'm going to buy two books in amazon in this week
Trust me, it's not about how easy, or how much it refers to your coding style when you're talking about VB.
It is just not worth it to learn it in comparison with c++, with c++ you can do so much more, its so much powerful.
Even if you want to write you're epic "irc bot", (ande,joepie,darkcocke (mostly ande, before he kicks my arse) wrote an pretty successful one in VB.net tough but...)   you will ALWAYS need to install .net runtime (as i expect you coding in vb.net).
And also the power, you can create a c++ app as slow as an vb.net app, but when you do it the right way, it can be SO MUCH more powerful.
We/I , am not blaming vb.net, or you, but most of us started with something similar to vb and know we know, we could have started c++ in the same time and be as good as we are now but in very less time (every minute you need to enjoy, and you enjoy more with c++ than vb).
So do me favor, and reconsider you're choice to start vb, if you want to create very easy stuff, do it, if you want to create smart,fast, powerful software go on with something like c++ instead mate :D