Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 00:16

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[VB] Inventar gut gelöst?

Discussion on [VB] Inventar gut gelöst? within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
dragonheart11's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 567
Received Thanks: 243
[VB] Inventar gut gelöst?

Hallo an alle,

ich hab mal eine kleine Inventar add Item Funktion geschrieben und wollt mal fragen ob das so recht dumm gelöst oder doch ganz ok:

Form mit den Items:
Code:
Public Class Items

    Private Sub Items_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Form2.Show()
    End Sub

    Private Sub Itm2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Itm2.Click
        Itm2.Visible = False
        Form2.Items.SelectedIndex = 0
        If Form2.Items.SelectedItem = "1" Then
            Form2.Items.SelectedIndex = 1
            If Form2.Items.SelectedItem = "1" Then
                Form2.Items.SelectedIndex = 2
                If Form2.Items.SelectedItem = "1" Then
                    Form2.Items.SelectedIndex = 3
                    If Form2.Items.SelectedItem = "1" Then
                        Form2.Items.SelectedIndex = 4
                        If Form2.Items.SelectedItem = "1" Then
                            Form2.Items.SelectedIndex = 5
                            If Form2.Items.SelectedItem = "1" Then
                                Form2.Items.SelectedIndex = 6
                                If Form2.Items.SelectedItem = "1" Then
                                    Form2.Items.SelectedIndex = 7
                                    If Form2.Items.SelectedItem = "1" Then
                                        Form2.Items.SelectedIndex = 8
                                        If Form2.Items.SelectedItem = "1" Then
                                            Form2.Items.SelectedIndex = 9
                                            If Form2.Items.SelectedItem = "1" Then

                                            Else
                                                Form2.Slot10.BackColor = Color.Blue
                                            End If
                                        Else
                                            Form2.Slot9.BackColor = Color.Blue
                                        End If
                                    Else
                                        Form2.Slot8.BackColor = Color.Blue
                                    End If
                                Else
                                    Form2.Slot7.BackColor = Color.Blue
                                End If
                            Else
                                Form2.Slot6.BackColor = Color.Blue
                            End If
                        Else
                            Form2.Slot5.BackColor = Color.Blue
                        End If
                    Else
                        Form2.Slot4.BackColor = Color.Blue
                    End If
                Else
                    Form2.Slot3.BackColor = Color.Blue
                End If
            Else
                Form2.Slot2.BackColor = Color.Blue
            End If
        Else
            Form2.Slot1.BackColor = Color.Blue
        End If
    End Sub

    Private Sub Itm3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Itm3.Click
        Itm3.Visible = False
        Form2.Items.SelectedIndex = 0
        If Form2.Items.SelectedItem = "1" Then
            Form2.Items.SelectedIndex = 1
            If Form2.Items.SelectedItem = "1" Then
                Form2.Items.SelectedIndex = 2
                If Form2.Items.SelectedItem = "1" Then
                    Form2.Items.SelectedIndex = 3
                    If Form2.Items.SelectedItem = "1" Then
                        Form2.Items.SelectedIndex = 4
                        If Form2.Items.SelectedItem = "1" Then
                            Form2.Items.SelectedIndex = 5
                            If Form2.Items.SelectedItem = "1" Then
                                Form2.Items.SelectedIndex = 6
                                If Form2.Items.SelectedItem = "1" Then
                                    Form2.Items.SelectedIndex = 7
                                    If Form2.Items.SelectedItem = "1" Then
                                        Form2.Items.SelectedIndex = 8
                                        If Form2.Items.SelectedItem = "1" Then
                                            Form2.Items.SelectedIndex = 9
                                            If Form2.Items.SelectedItem = "1" Then

                                            Else
                                                Form2.Slot10.BackColor = Color.Red
                                            End If
                                        Else
                                            Form2.Slot9.BackColor = Color.Red
                                        End If
                                    Else
                                        Form2.Slot8.BackColor = Color.Red
                                    End If
                                Else
                                    Form2.Slot7.BackColor = Color.Red
                                End If
                            Else
                                Form2.Slot6.BackColor = Color.Red
                            End If
                        Else
                            Form2.Slot5.BackColor = Color.Red
                        End If
                    Else
                        Form2.Slot4.BackColor = Color.Red
                    End If
                Else
                    Form2.Slot3.BackColor = Color.Red
                End If
            Else
                Form2.Slot2.BackColor = Color.Red
            End If
        Else
            Form2.Slot1.BackColor = Color.Red
        End If
    End Sub
End Class
Inventar:
Code:
Public Class Inventar
    Dim s1 As Integer
    Dim s2 As Integer
    Dim s3 As Integer
    Dim s4 As Integer
    Dim s5 As Integer
    Dim s6 As Integer
    Dim s7 As Integer
    Dim s8 As Integer
    Dim s9 As Integer
    Dim s10 As Integer

    Private Sub ItemsC_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ItemsC.Tick
        Items.Items.Clear()
        Items.Items.Add(s1)
        Items.Items.Add(s2)
        Items.Items.Add(s3)
        Items.Items.Add(s4)
        Items.Items.Add(s5)
        Items.Items.Add(s6)
        Items.Items.Add(s7)
        Items.Items.Add(s8)
        Items.Items.Add(s9)
        Items.Items.Add(s10)
    End Sub

    Private Sub Slot1_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Slot1.BackColorChanged
        s1 = 1
    End Sub

    Private Sub Slot2_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Slot2.BackColorChanged
        s2 = 1
    End Sub

    Private Sub Slot3_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Slot3.BackColorChanged
        s3 = 1
    End Sub

    Private Sub Slot4_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Slot4.BackColorChanged
        s4 = 1
    End Sub

    Private Sub Slot5_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Slot5.BackColorChanged
        s5 = 1
    End Sub

    Private Sub Slot6_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Slot6.BackColorChanged
        s6 = 1
    End Sub

    Private Sub Slot7_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Slot7.BackColorChanged
        s7 = 1
    End Sub

    Private Sub Slot8_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Slot8.BackColorChanged
        s8 = 1
    End Sub

    Private Sub Slot9_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Slot9.BackColorChanged
        s9 = 1
    End Sub

    Private Sub Slot10_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Slot10.BackColorChanged
        s10 = 1
    End Sub
End Class
Danke schon mal fürs anschauen und natürlich anstatt Farben -> Bilder^^
dragonheart11 is offline  
Old 09/17/2013, 23:57   #2
 
elite*gold: 100
Join Date: Aug 2005
Posts: 595
Received Thanks: 208
Also den ersten Codeteil den du gepostet hast find ich toll, hast vor es als Moderne Kunst zu verkaufen ? :P
dready is offline  
Thanks
3 Users
Old 09/18/2013, 00:17   #3
 
dragonheart11's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 567
Received Thanks: 243
Quote:
Originally Posted by dready View Post
Also den ersten Codeteil den du gepostet hast find ich toll, hast vor es als Moderne Kunst zu verkaufen ? :P
Klar^^
ne ist die abfrage slot für slot ob ein slot schon ein item besitzt
dragonheart11 is offline  
Old 09/18/2013, 00:31   #4
 
elite*gold: 0
Join Date: Jan 2012
Posts: 759
Received Thanks: 416
Ich habe irgendwo einmal gehört, es gäbe sowas wie "Schleifen". Vielleicht war das aber auch nur ein Gerücht.
dowhile is offline  
Thanks
1 User
Old 09/18/2013, 00:45   #5
 
dragonheart11's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 567
Received Thanks: 243
Also nicht grad die beste lösung von mir^^
dragonheart11 is offline  
Old 09/18/2013, 00:59   #6
 
Bloody*Star's Avatar
 
elite*gold: 0
Join Date: Sep 2013
Posts: 14
Received Thanks: 4
Lightbulb

dude learn about select case instead of using so many if then... it will make your code more organize and simple to understand and not all over the place. ex
Code:
select case Form2.Items.SelectedIndex
case 0
        If Form2.Items.SelectedItem = "1" Then
            Form2.Items.SelectedIndex = 1
        Else
            Form2.Slot1.BackColor = Color.Blue
        End If
end select
Bloody*Star is offline  
Old 09/18/2013, 08:55   #7
 
elite*gold: 5
Join Date: Mar 2008
Posts: 460
Received Thanks: 436
Man sollte nicht mehr als 3-4 insichgehende Verzweigungen haben und das auch nur bei komplexen sachen. Setz dir das als Grundregel.

Alles was mehr hat, kannst du von Grundaussagen es ist schlecht und gehört anderst gelöst.
SwarN is offline  
Thanks
2 Users
Old 09/19/2013, 17:32   #8
 
[uLow]NTX?!'s Avatar
 
elite*gold: 0
Join Date: May 2013
Posts: 1,266
Received Thanks: 627
Quote:
Originally Posted by dready View Post
Also den ersten Codeteil den du gepostet hast find ich toll, hast vor es als Moderne Kunst zu verkaufen ? :P
Quote:
Originally Posted by dowhile View Post
Ich habe irgendwo einmal gehört, es gäbe sowas wie "Schleifen". Vielleicht war das aber auch nur ein Gerücht.
Sowas von unnötig, er fragt ob das so gut ist und wenn nein wie man es besser machen kann und ihr bzw vorallem dready posten son müll.....
Dafür hat dready auchn report und bekommt hoffentlich eine Infra dafür.

Btt.: nein die art ist ganz und garnicht gut, wie oben erwähnt solltest du schleifen nutzen. Und evtl erläutern was das genau machen soll.
[uLow]NTX?! is offline  
Thanks
1 User
Old 09/19/2013, 18:17   #9
 
elite*gold: 100
Join Date: Aug 2005
Posts: 595
Received Thanks: 208
Meine Güte .. das ganze nennt man Humor, was der Smiley eigentlich auch Zeigen sollte.

Falls es dir nicht aufgefallen ist, ich hab seine Frage beantwortet, und darauf hingewiesen das der erste Codeteil eine Ascii-Art ist nämlich exakt das hier auf die seite gelegt:

^^
dready is offline  
Thanks
4 Users
Old 09/20/2013, 07:56   #10
 
elite*gold: 0
Join Date: Mar 2011
Posts: 124
Received Thanks: 3
Ich würde es mal mit der "Select Case" Funktion versuchen. Die ganzen If Funktionen gehen auf die dauer nicht gut und wenn du dein Projekt weiterführen willst würde ich es dir empfehelen. Nicht nur wegen der Übersicht ^^

kannst mich auch mal Privat anschreiben, ich helfe dir gerne!
nawiat is offline  
Reply


Similar Threads Similar Threads
Gelöst#
03/29/2013 - Technical Support - 0 Replies
/
/gelöst
04/24/2012 - Aion - 2 Replies
/
[B] Hoot acc gold prem full Inventar super Inventar [S] PSC,G1,e*gold
02/18/2012 - WarRock Trading - 0 Replies
title sagt alles pw&e.mail wird changed KD 1.4 FULL INVENTAR SUPER INVENTAR Dinar 34000 jo für mehr INFORMATION SCHREIBT IM Therad l.v 18 GOLD premium 24 Tage
Guter Acc. mit gefülltem Inventar ~ und reichlich Inventar!
11/16/2011 - WarRock Trading - 0 Replies
Bietet einen Preis für den Acc. http://www8.pic-upload.de/16.11.11/z6b1c64vn3ih.p ng http://www8.pic-upload.de/16.11.11/uw7vgjqfxh.png http://www8.pic-upload.de/16.11.11/khnex4rl9nd5.p ng http://www8.pic-upload.de/16.11.11/f2oh9cf4zz5.pn g http://www8.pic-upload.de/16.11.11/z7oyebniuydz.p ng http://www8.pic-upload.de/16.11.11/ssijoky7pxbo.p ng
TAUSCHE ACC LVL 29 (MIT GUTEM INVENTAR) gegen einen acc lvl 41+ mit blankem inventar
01/06/2011 - WarRock Trading - 0 Replies
moin ich tausche oder VK meine acc lvl 29 also jez mal zum inventar Magnum Magnum Lease Remaining: 3 day(s) FAMAS FAMAS Lease Remaining: 13 day(s)



All times are GMT +1. The time now is 00:16.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.