Author Topic: [VB2010] if,else,then,i/o problem  (Read 4810 times)

0 Members and 2 Guests are viewing this topic.

Offline gh0st

  • Sir
  • ***
  • Posts: 575
  • Cookies: 8
  • #DEDSec
    • View Profile
[VB2010] if,else,then,i/o problem
« on: April 17, 2011, 02:07:37 am »
guys Ive just started to learn VB and Ive coded this:

Code: [Select]
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:
Code: [Select]
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/
« Last Edit: April 17, 2011, 02:43:10 am by gh0st »

Offline Zesh

  • Royal Highness
  • ****
  • Posts: 699
  • Cookies: 42
    • View Profile
Re: [VB2010] if,else,then,i/o problem
« Reply #1 on: 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

Code: [Select]
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

Code: [Select]
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
« Last Edit: April 17, 2011, 02:22:54 am by Zesh »


Offline ande

  • Owner
  • Titan
  • *
  • Posts: 2664
  • Cookies: 256
    • View Profile
Re: [VB2010] if,else,then,i/o problem
« Reply #2 on: 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.
if($statement) { unless(!$statement) { // Very sure } }
https://evilzone.org/?hack=true

Offline 10n1z3d

  • Serf
  • *
  • Posts: 42
  • Cookies: 8
    • View Profile
Re: [VB2010] if,else,then,i/o problem
« Reply #3 on: April 17, 2011, 09:58:23 am »
Friendly advice: Leave VB.NET and start C# before it's too late.
« Last Edit: April 17, 2011, 10:16:54 am by 10n1z3d »
Code: [Select]
python -c "print ''.join(chr(x) for x in [int(oct(39)) + 2, 24 * 2, 313 % 203, 0x31, (2 ** 7) - 6, int('051'), (3 << 6) - 92])"

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
Re: [VB2010] if,else,then,i/o problem
« Reply #4 on: 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.
~Factionwars

Offline 10n1z3d

  • Serf
  • *
  • Posts: 42
  • Cookies: 8
    • View Profile
Re: [VB2010] if,else,then,i/o problem
« Reply #5 on: April 18, 2011, 11:26:21 am »
Quote from: 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.
« Last Edit: April 18, 2011, 11:29:15 am by 10n1z3d »
Code: [Select]
python -c "print ''.join(chr(x) for x in [int(oct(39)) + 2, 24 * 2, 313 % 203, 0x31, (2 ** 7) - 6, int('051'), (3 << 6) - 92])"

Offline gh0st

  • Sir
  • ***
  • Posts: 575
  • Cookies: 8
  • #DEDSec
    • View Profile
Re: [VB2010] if,else,then,i/o problem
« Reply #6 on: April 19, 2011, 04:56:16 pm »
I got the answer thanx btw

Offline Xires

  • Noob Eater
  • Administrator
  • Knight
  • *
  • Posts: 379
  • Cookies: 149
    • View Profile
    • Feed The Trolls - Xires
Re: [VB2010] if,else,then,i/o problem
« Reply #7 on: 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?
-Xires

Offline gh0st

  • Sir
  • ***
  • Posts: 575
  • Cookies: 8
  • #DEDSec
    • View Profile
Re: [VB2010] if,else,then,i/o problem
« Reply #8 on: 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

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
Re: [VB2010] if,else,then,i/o problem
« Reply #9 on: 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
~Factionwars