Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.scripting.vbscript > #11972 > unrolled thread

hide user input in vb

Started bylysaali50@gmail.com
First post2018-06-07 13:53 -0700
Last post2018-06-08 21:49 +0200
Articles 6 — 5 participants

Back to article view | Back to microsoft.public.scripting.vbscript


Contents

  hide user input in vb lysaali50@gmail.com - 2018-06-07 13:53 -0700
    Re: hide user input in vb "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-06-07 23:07 +0200
    Re: hide user input in vb "Mayayana" <mayayana@invalid.nospam> - 2018-06-07 17:52 -0400
    Re: hide user input in vb JJ <jj4public@vfemail.net> - 2018-06-08 13:06 +0700
    Re: hide user input in vb "R.Wieser" <address@not.available> - 2018-06-08 10:20 +0200
      Re: hide user input in vb "R.Wieser" <address@not.available> - 2018-06-08 21:49 +0200

#11972 — hide user input in vb

Fromlysaali50@gmail.com
Date2018-06-07 13:53 -0700
Subjecthide user input in vb
Message-ID<24696fad-a3f0-492f-aeb4-f0688cd0deab@googlegroups.com>
i'm new to visual basic and i want to make a 2 player game where player1 inputs a number and player2 has to guess it

i'm having trouble in finding ways to hide user inputs so that player2 has to actually guess the number

here's my code so far:
Module Module1

    Sub Main()
        Dim guess As Integer = 0
        Dim N2guess As Integer = 0
        Dim attempts As Integer = 0
        Dim P1 As String = "P1"
        Dim P2 As String = "P2"

        Console.WriteLine("P1, please enter a number between 1-10 ")
        N2guess = Console.ReadLine()
        While N2guess < 1 Or N2guess > 10
            Console.WriteLine("INVALID OPTION")
            Console.WriteLine("please try again")
            N2guess = Console.ReadLine()
        End While


        While guess <> N2guess And attempts < 5
            Console.WriteLine("P2 have a guess")
            guess = Console.ReadLine()
            attempts = attempts + 1
        End While

        If guess = N2guess Then
            Console.WriteLine("P2 WINS!")
        Else
            Console.WriteLine("P1 WINS!")
        End If
        Console.ReadLine()
    End Sub

End Module

[toc] | [next] | [standalone]


#11973

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2018-06-07 23:07 +0200
Message-ID<XnsA8FAEB521343Deejj99@194.109.6.166>
In reply to#11972
lysaali50@gmail.com wrote on 07 Jun 2018 in
microsoft.public.scripting.vbscript: 

> i'm new to visual basic and i want to make a 2 player game where player1
> inputs a number and player2 has to guess it 

This NG is about the scriptig language VBS, NOT about VB.

> 
> i'm having trouble in finding ways to hide user inputs so that player2
> has to actually guess the number 
> 
> here's my code so far:
> Module Module1
> 
>     Sub Main()
>         Dim guess As Integer = 0
>         Dim N2guess As Integer = 0
>         Dim attempts As Integer = 0
>         Dim P1 As String = "P1"
>         Dim P2 As String = "P2"
> 
>         Console.WriteLine("P1, please enter a number between 1-10 ")
>         N2guess = Console.ReadLine()
>         While N2guess < 1 Or N2guess > 10
>             Console.WriteLine("INVALID OPTION")
>             Console.WriteLine("please try again")
>             N2guess = Console.ReadLine()
>         End While
> 
> 
>         While guess <> N2guess And attempts < 5
>             Console.WriteLine("P2 have a guess")
>             guess = Console.ReadLine()
>             attempts = attempts + 1
>         End While
> 
>         If guess = N2guess Then
>             Console.WriteLine("P2 WINS!")
>         Else
>             Console.WriteLine("P1 WINS!")
>         End If
>         Console.ReadLine()
>     End Sub
> 
> End Module
> 



-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#11974

From"Mayayana" <mayayana@invalid.nospam>
Date2018-06-07 17:52 -0400
Message-ID<pfc9g6$iuv$1@dont-email.me>
In reply to#11972
<lysaali50@gmail.com> wrote

| i'm new to visual basic and i want to make a 2 player game where player1 
inputs a number and player2 has to guess it
|
| i'm having trouble in finding ways to hide user inputs so that player2 has 
to actually guess the number
|

 There could be different options. A password
input. Or maybe a custom design. For instance,
#1 enters "21" and clicks a button, which then
puts "21" into texbox 2. But textbox 2
is red background with red forecolor. If #2
guesses the number then textbox 2 background
turns white to show the matching number in red.

  .... Just an idea. You could use asll sorts of methods.

  As Evertjian said, this group is for VBS. VBScript
is similar to VB, but it's text-based code with no
data types. Everything is a variant. VBS is very
similar to the most primitive version of VB.

  VB refers to VB5 or 6. This is pretty much
the last active group:

microsoft.public.vb.general.discussion

  Then there's also VB.Net. Some people who
don't know about VB call VB.Net VB. So it can
get confusing. VB.Net is very different from
both VB and VBS. VB is to VB.Net sort of like
C++ is to Java. VB is used to write compiled
software that uses ActiveX controls, COM,
and the Win32 API. VB.Net mainly uses the
.Net runtime, similar to Java, and creates
"assemblies" that run JIT-compiled.

   If you're using VB.Net thre are also newsgroups
for that, but I don't remember what they are offhand.
Do a search of group names for "dotnet".

   If those are no longer busy then another
 option would be to join the Microsoft Web forums.
Unfortunately, those are web-based, so the
format is very inefficient. Also, you have to
join and the groups are moderated by Microsofties.
The result is more a marketing venue than a
discussion. 

[toc] | [prev] | [next] | [standalone]


#11975

FromJJ <jj4public@vfemail.net>
Date2018-06-08 13:06 +0700
Message-ID<vuqv1qvy2c7v$.1vgbz480bycfz.dlg@40tude.net>
In reply to#11972
On Thu, 7 Jun 2018 13:53:05 -0700 (PDT), lysaali50@gmail.com wrote:
> i'm new to visual basic and i want to make a 2 player game where player1
> inputs a number and player2 has to guess it 
> 
> i'm having trouble in finding ways to hide user inputs so that player2
> has to actually guess the number
[snip]

For a VB application, IMO, the easiest way is to move the console cursor up
one line where the previous user inputted number is shown, then outputs
space characters to overwrite the number characters.

I don't know if VBA runtime library has a built in function that modifies
the console cursor, not not. If it doesn't, then you'll need to call the
Windows' Console API functions directly.

[toc] | [prev] | [next] | [standalone]


#11976

From"R.Wieser" <address@not.available>
Date2018-06-08 10:20 +0200
Message-ID<pfde8o$1ij$1@gioia.aioe.org>
In reply to#11972
lysaali,

> i'm having trouble in finding ways to hide user inputs so that player2 has 
> to actually guess the number

You could print a number of blank lines (in a "for" loop) after player #1 
has input the number, so it will be pushed down and off the screen.

... that is, if "Console.Clear" doesn't work for you (I have no idea which 
version of Visual Basic you're running.  The beforementioned "Clear" seems 
to work for the .NET version)

Regards,
Rudy Wieser

[toc] | [prev] | [next] | [standalone]


#11977

From"R.Wieser" <address@not.available>
Date2018-06-08 21:49 +0200
Message-ID<pfemla$d1u$1@gioia.aioe.org>
In reply to#11976
> so it will be pushed down and off the screen.

Up!  Pushed *up* and off the the screen ofcourse.

Regards,
Rudy Wieser

[toc] | [prev] | [standalone]


Back to top | Article view | microsoft.public.scripting.vbscript


csiph-web