name limit
name limit
name limit
name limit
name limit
name limit name limit name limit name limit name limit name limit name limit name limit
name limit name limit
name limit
Go Back  Xtreme Visual Basic Talk > > > name limit


Reply
 
Thread Tools Display Modes
  #1  
Old 03-04-2011, 05:00 AM
Williams92 Williams92 is offline
Newcomer
 
Join Date: Feb 2011
Location: Wimborne, Dorset, UK
Posts: 7
Default name limit


Hello,

I've got a bit of code which i am struggling with for a school project. It's for a pong game and I want to put a minimum and maximum amount of letters into the imput box but the different codes i've tried haven't worked. If anyone could help I would be very greatful.
Reply With Quote
  #2  
Old 03-04-2011, 07:45 AM
Cerian Knight's Avatar
Cerian Knightname limit Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,199
Default

Show us an example of the code you have tried so we can better understand what you are trying to do.

Have a look at our Posting Guidelines when you have a chance and welcome to the forum.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #3  
Old 03-07-2011, 03:40 AM
Williams92 Williams92 is offline
Newcomer
 
Join Date: Feb 2011
Location: Wimborne, Dorset, UK
Posts: 7
Default

Thanks for the welcome.

Here's the bits of code I use for the names

A = 0
With Player(A)
.Name = InputBox("Enter name for player " & CStr(A + 1) & ":", "Player 1")

A = 1
With Player(A)
.Name = InputBox("Enter name for player " & CStr(A + 1) & ":", "Player 2")

It's clear that it offers the Input box to put the name in but It doesn't limit you. I tried it before with about 15 digits and, even though it was not shown in the "Game Over" box, it still counted for some reason.
Reply With Quote
  #4  
Old 03-07-2011, 10:09 AM
Gruff's Avatar
Gruffname limit Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

Hope you don't mind CK.

The inputbox is very limited.
If you need to control input write your own input box dialog.

BTW Ever notice that CK and Clark Kent have the same initials?
Never see them in the same room at the same time either. Hmmmm.
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
  #5  
Old 03-07-2011, 10:28 AM
Cerian Knight's Avatar
Cerian Knightname limit Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,199
Default

I agree, Gruff, as I never use InputBox due to its inherent limitations. But, perhaps something simple, such as a Do...While loop will work. For example:
Code:
Do
  .Name = InputBox("Enter name for player (1-14 characters) " & CStr(A + 1) & ":", "Player 1") 
Loop While Len(.Name) < 1 Or Len(.Name) >= 15
That approach is worth a 'B'.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').

Last edited by Cerian Knight; 03-09-2011 at 07:46 AM. Reason: Added 'Loop' to 'While' and changed 'And' to 'Or'
Reply With Quote
  #6  
Old 03-09-2011, 06:35 AM
Williams92 Williams92 is offline
Newcomer
 
Join Date: Feb 2011
Location: Wimborne, Dorset, UK
Posts: 7
Default

I'm still having trouble. I've tried replacing the code with the bit given by Cerian Knight but for some reason, it then expects me to replace everything. Once i've done that, for some reason, it continuously keeps the screen the same on the input box. I'll paste all of the form but is it something i did wrong in the coding? It brings a pop up box saying "End With without With", I delete that. It then says "While without Wend". I put the Wend below the new lines but then it says "Do without Loop". Could it be this causing it?
Code:
Private Sub Form_Load()
    Dim A As Long
    Dim Temp As String
    
    'General
    Active = True
    MaxFPS = 40
    ReDim KD(255)
    
    PadSpeed = 20
    PadAcceleration = 1
    
    BallSpeed = 10
    BallAcceleration = 1.1
    
    Friction = 0.5
    
    'Setup window
    With Me
        'General
        .Caption = "2 Player Game: Pong"
        
        'Drawing
        .BackColor = 0
        .ScaleMode = vbPixels
        .FillStyle = 0
        .Font = "Curlz MT"
        .FontSize = 30
        .FontBold = False
        .AutoRedraw = True
        
        'Size and position
        .Width = 19000
        .Height = 14000
        .Move (Screen.Width - .Width) / 2, (Screen.Height - .Height) / 2
    End With
    
    'Allocate memory
    PlayerCount = 1
    ReDim Player(1)
    
    BallCount = 0
    ReDim Ball(BallCount)
    
    'User setup
    A = 0
    With Player(A)
        Do
        .Name = InputBox("Enter name for player (1-14 characters) " & CStr(A + 1) & ":", "Player 1")
        While Len(.Name) < 1 And Len(.Name) >= 15        
        With .KeyTable
            'Keys
            .KeyUp = vbKeyW
            .KeyDown = vbKeyS 'vbKeyZ
        End With
        
        'Individual setup
        With .Pad
            'Size
            .w = 10
            .h = 100
            
            'Start position
            .x = 25
            .y = (Camera.h - .h) / 2
            
            'Movement
            .SpeedX = 0
            .SpeedY = 0
            
            'General
            .IsBall = False
            .Color = RGB(135, 205, 255)
        End With
        
        'Key-help
        Temp = Temp & "Player " & CStr(A + 1) & ": " & Chr(Player(A).KeyTable.KeyUp) & _
            " and " & Chr(Player(A).KeyTable.KeyDown) & vbNewLine
    End With
    
    A = 1
    With Player(A)
       Do
        .Name = InputBox("Enter name for player (1-14 characters) " & CStr(A + 1) & ":", "Player 2")
        While Len(.Name) < 1 And Len(.Name) >= 15        
        With .KeyTable
            'Keys
            .KeyUp = vbKeyI
            .KeyDown = vbKeyK
        End With
        
        'Individual setup
        With .Pad
            'Size
            .w = 10
            .h = 100
            
            'Start position
            .x = Camera.w - .w - 35
            .y = (Camera.h - .h) / 2
            
            'Movement
            .SpeedX = 0
            .SpeedY = 0
            
            'General
            .IsBall = False
            .Color = RGB(124, 252, 0)
        End With
        
        'Key-help
        Temp = Temp & "Player " & CStr(A + 1) & ": " & Chr(Player(A).KeyTable.KeyUp) & _
            " and " & Chr(Player(A).KeyTable.KeyDown) & vbNewLine
    End With
    
    MsgBox "Key configuration:" & vbNewLine & vbNewLine & Temp, vbInformation
    
    For A = 0 To BallCount
        With Ball(A)
            'Size
            .w = 10
            .h = 10
            
            InitBall Ball(A)
            
            'General
            .IsBall = True
            .Color = RGB(255, 165, 0)
        End With
    Next
    
    'Run
    Me.Show
    Main
End Sub

Last edited by Williams92; 03-09-2011 at 06:44 AM. Reason: Searching for bug
Reply With Quote
  #7  
Old 03-09-2011, 07:41 AM
Cerian Knight's Avatar
Cerian Knightname limit Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,199
Default

My example 'air' code was not exactly correct (syntactically or logically). I changed it a bit, if that helps (see my previous post).
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #8  
Old 03-10-2011, 03:17 AM
Williams92 Williams92 is offline
Newcomer
 
Join Date: Feb 2011
Location: Wimborne, Dorset, UK
Posts: 7
Default

Ok Thank you, that has solved the problem.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
name limit
name limit
name limit name limit
name limit
name limit
name limit name limit name limit name limit name limit name limit name limit
name limit
name limit
 
name limit
name limit
 
-->