Pink Poogle Toy Forum

The official community of Pink Poogle Toy
Main Site
NeoDex
It is currently Fri Nov 29, 2024 1:21 am

All times are UTC




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: vb express 2005 question
PostPosted: Sat Sep 17, 2005 1:18 am 
Beyond Godly
Beyond Godly
User avatar

Posts: 2679
Joined: Wed Jun 02, 2004 1:03 am
Location: Uh... Nowhere Set: Blue
Gender: Male
any way I can make the following less tedious? It's _really_ huge. (And I have to use similar code in 48 versions of this. pain!)

Code:
If Label1.Text = "Pick 6 members for Team One" Then
            Dim BillTM As Byte
            BillTM = 1
            Button1.Visible = False
            Label1.Text = "Pick 5 members for Team One"
        ElseIf Label1.Text = "Pick 5 members for Team One" Then
            Dim BillTM As Byte
            BillTM = 2
            Button1.Visible = False
            Label1.Text = "Pick 4 members for Team One"
        ElseIf Label1.Text = "Pick 4 members for Team One" Then
            Dim BillTM As Byte
            BillTM = 3
            Button1.Visible = False
            Label1.Text = "Pick 3 members for Team One"
        ElseIf Label1.Text = "Pick 3 members for Team One" Then
            Dim BillTM As Byte
            BillTM = 4
            Button1.Visible = False
            Label1.Text = "Pick 2 members for Team One"
        ElseIf Label1.Text = "Pick 2 members for Team One" Then
            Dim BillTM As Byte
            BillTM = 5
            Button1.Visible = False
            Label1.Text = "Pick 1 member for Team One"
        ElseIf Label1.Text = "Pick 1 member for Team One" Then
            Dim BillTM As Byte
            BillTM = 6
            Button1.Visible = False
            Label1.Text = "Pick 6 members for Team Two"
        ElseIf Label1.Text = "Pick 6 members for Team Two" Then
            Dim BillTM As Byte
            BillTM = 7
            Button1.Visible = False
            Label1.Text = "Pick 5 members for Team Two"
        ElseIf Label1.Text = "Pick 5 members for Team Two" Then
            Dim BillTM As Byte
            BillTM = 8
            Button1.Visible = False
            Label1.Text = "Pick 4 members for Team Two"
        ElseIf Label1.Text = "Pick 4 members for Team Two" Then
            Dim BillTM As Byte
            BillTM = 9
            Button1.Visible = False
            Label1.Text = "Pick 3 members for Team Two"
        ElseIf Label1.Text = "Pick 3 members for Team Two" Then
            Dim BillTM As Byte
            BillTM = 10
            Button1.Visible = False
            Label1.Text = "Pick 2 members for Team Two"
        ElseIf Label1.Text = "Pick 2 members for Team Two" Then
            Dim BillTM As Byte
            BillTM = 11
            Button1.Visible = False
            Label1.Text = "Pick 1 member for Team Two"
        ElseIf Label1.Text = "Pick 1 member for Team Two" Then
            Dim BillTM As Byte
            BillTM = 12
            Button1.Visible = False
            Label1.Text = "Please confirm that you would like to pick these people for the first team line up."


Image


Top
 Profile  
 
 Post subject: Re: vb express 2005 question
PostPosted: Sat Sep 17, 2005 9:01 am 
Administrator
Administrator
User avatar

Posts: 1140
Joined: Mon May 31, 2004 1:36 pm
Tested wrote:
any way I can make the following less tedious? It's _really_ huge. (And I have to use similar code in 48 versions of this. pain!)
Code:
...

First of all, move the variable declares outside the if. It's best to declare variables at the start of the function / subroutine, rather than when they're needed.
You seem to do Button1.Visible = False on every single path you can take through the thing. Reduntant, move it outside of the IF.
You don't seem to use BillTM -- I'm assuming you need it somewhere, although you could just optimize that away.

With a little bit of string functions (and missing error checking) you can arrive at this:
Code:
Dim BillTM As Byte, pickteam as string, pickpeople as long

pickteam = Right(Label1.Text,3)
pickpeople = Val(Mid(Label1.Text,6,1))
Button1.Visible = False ' You never seem to set this to true anyway

if pickteam = "One" Then
   if pickpeople = 1 then
      Label1.Text = "Pick 6 members for team Two"
   else
      Label1.Text = "Pick " & (pickpeople-1) & " member" & iif((pickpeople-1)=1,"","s") & " for Team " & pickteam
   end   
   BillTM = 7 - pickpeople
ElseIf pickteam = "Two" then
   if pickpeople = 1 then
      Label1.Text = "Please confirm that you would like to pick these people for the first team line up."
   else
      Label1.Text = "Pick " & (pickpeople-1) & " member" & iif((pickpeople-1)=1,"","s") & " for Team " & pickteam
   end
   BillTM = (7 - pickpeople) + 6
End If

(I apologise if any PHP or LUA syntax sneaked in there. Haven't used VB in a while.)


Image
Will you stop with the honour stuff?


Top
 Profile  
 
 Post subject: Re: vb express 2005 question
PostPosted: Sun Sep 18, 2005 1:27 am 
Beyond Godly
Beyond Godly
User avatar

Posts: 2679
Joined: Wed Jun 02, 2004 1:03 am
Location: Uh... Nowhere Set: Blue
Gender: Male
Hunter Lupe wrote:
Tested wrote:
any way I can make the following less tedious? It's _really_ huge. (And I have to use similar code in 48 versions of this. pain!)
Code:
...

First of all, move the variable declares outside the if. It's best to declare variables at the start of the function / subroutine, rather than when they're needed.
You seem to do Button1.Visible = False on every single path you can take through the thing. Reduntant, move it outside of the IF.
You don't seem to use BillTM -- I'm assuming you need it somewhere, although you could just optimize that away.

With a little bit of string functions (and missing error checking) you can arrive at this:
Code:
Dim BillTM As Byte, pickteam as string, pickpeople as long

pickteam = Right(Label1.Text,3)
pickpeople = Val(Mid(Label1.Text,6,1))
Button1.Visible = False ' You never seem to set this to true anyway

if pickteam = "One" Then
   if pickpeople = 1 then
      Label1.Text = "Pick 6 members for team Two"
   else
      Label1.Text = "Pick " & (pickpeople-1) & " member" & iif((pickpeople-1)=1,"","s") & " for Team " & pickteam
   end   
   BillTM = 7 - pickpeople
ElseIf pickteam = "Two" then
   if pickpeople = 1 then
      Label1.Text = "Please confirm that you would like to pick these people for the first team line up."
   else
      Label1.Text = "Pick " & (pickpeople-1) & " member" & iif((pickpeople-1)=1,"","s") & " for Team " & pickteam
   end
   BillTM = (7 - pickpeople) + 6
End If

(I apologise if any PHP or LUA syntax sneaked in there. Haven't used VB in a while.)


Thanks!
Also, button1 is the button used to pick Bill for a team, so
Quote:
button1.visible = false
keeps the user from picking Bill twice.

You can lock this now.


Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 20 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group