Results 1 to 13 of 13

Thread: VB.net Question     submit to reddit submit to twitter

  1. #1
    Banned.

    Join Date
    Jul 2005
    Posts
    5,821
    BG Level
    8
    FFXI Server
    Sylph
    WoW Realm
    Arthas

    VB.net Question

    Yes, I'm aware VB.net sucks.

    I really dunno what all info I need for this. I am making a program that handles LS situations and whatnot. Its called LinkshellLeaderPro, its really a learning project for me. I've hit a kind of stump here ><

    I need to loop thru a checklist box and add points to every member in the check list. I have it display all of my info I need in a msgbox showing me its reading what its checked, but it wont add points to the selected people..

    If you ABSOLUTLY need the sorce code for this I dont mind sending it to you, but I really rather not. If you can help me with the info I provided that would be great. If you have any questions I will be happy to awnser.


    Code:
    Code:
        Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
            Dim itemChecked As Object
            For Each ctrl As Control In Me.Calendarandevent.Controls
                If TypeOf ctrl Is CheckedListBox Then
                    For Each itemChecked In chkbox1.CheckedItems
                        MessageBox.Show(idEditing.ToString)
                        personEditing = CType(itemChecked, Person)
                        idEditing = chkbox1.Items.IndexOf(personEditing) 
                        var2 = CDbl(personEditing.Points)
                        var3 = CDbl(TextBox3.Text)
                        var2 = var2 + var3
                        personEditing.Points = CStr(var2)
                        Call SaveList()
                        Call ReadList()
                    Next
                End If
            Next
        End Sub
    Any help would be great. Thank you.

  2. #2
    Chram
    Join Date
    Jun 2006
    Posts
    2,539
    BG Level
    7

    Eh.. So what determines what names are there to be checked?

    What if they need a different amount of points than everyone else?

  3. #3
    Fake Numbers
    Join Date
    Mar 2005
    Posts
    98
    BG Level
    2

    Are your members defined as an array?

  4. #4
    Chram
    Join Date
    Jun 2006
    Posts
    2,539
    BG Level
    7

    I wrote my linkshell point management system a long time ago in 5 min total, it has worked perfect without a single bug or flaw longer than most people on these forums have been level 75.

    It could use cleanup.. but I don't care.. You write an entire package in 5 min without bugs

    This is the equivalent of the page you are trying to make except in php.

    Code:
    <? require("../glimpse.php"); securezone();
    if(!$exodus_dkp) { redirect("main.php"); exit(); }
    
    $database = new Psql("dbname=exodus user=bleach");
    $id = $addslashes($_GET[id]); if(!$id) redirect("events.php");
    
    $event = new Result($database, "select e.id, r.name as \"type\", e.description,
    e.date, e. time, e.creator, e.dkp, e.results from tbl_event e, tbl_raid r where
    e.id = '$id' and e.raid = r.id order by e.date");
    
    if (!$event->fetcharray())
    {
      redirect("events.php");
      exit();
    }
    
    if(clicked("addattendie"))
    {
      if($_POST[attendiename] && $_POST[attendiedkp])
      {
        $database->exec("insert into tbl_dkp (event, dkp, member, note) values ('$id
    ','" . addslashes($_POST[attendiedkp]) . "','" . addslashes($_POST[attendiename]
    ) . "','Attendence')");
        $database->exec("update tbl_event set creator='" . $_SESSION[exodus_username
    ] . "' where id='$id'");
      }
      redirect("viewevent.php?id=$id"); exit();
    }
    
    if(clicked("adddrop"))
    {
      if($_POST[dropitem] && $_POST[dropmember])
      {
        $dkp = new Result($database, "select name, dkp from tbl_item where id='" . $
    _POST[dropitem] . "'");
        $dkp->fetcharray();
        if($_POST[dropvalue]) $dkp->row[dkp] = addslashes($_POST[dropvalue]);
        $database->exec("insert into tbl_dkp (event, dkp, member, note) values ('$id
    ','-" . $dkp->row[dkp] . "','" . addslashes($_POST[dropmember]) . "','" . addsla
    shes($dkp->row[name]) . "')");
        $database->exec("update tbl_event set creator='" . $_SESSION[exodus_username
    ] . "' where id='$id'");
      }
      redirect("viewevent.php?id=$id"); exit();
    }
    
    if($_GET[delete_attendie])
    {
      $database->exec("delete from tbl_dkp where id='".addslashes($_GET[delete_atten
    die])."'");
      $database->exec("update tbl_event set creator='" . $_SESSION[exodus_username]
    . "' where id='$id'");
      redirect("viewevent.php?id=$id"); exit();
    }
    
    if($_GET[delete_drop])
    {
      $database->exec("delete from tbl_dkp where id='".addslashes($_GET[delete_drop]
    )."'");
      $database->exec("update tbl_event set creator='" . $_SESSION[exodus_username]
    . "' where id='$id'");
      redirect("viewevent.php?id=$id"); exit();
    }
    
    if(clicked("updatedetails"))
    {
      $database->exec("update tbl_event set creator='" . $_SESSION[exodus_username]
    . "', results='" . addslashes(htmlentities($_POST[results])) . "' where id='$id'
    ");
      redirect("viewevent.php?id=$id"); exit();
    }
    
    $webpage = new Html();
    $webpage->start("view event");
    $webpage->formstart("viewevent.php?id=$id");
    echo "<a href=\"main.php\">Return to main</a>
    \n";
    echo "<a href=\"events.php\">Return to events</a>
    
    \n";
    echo "<input type=\"hidden\" name=\"id\" value=\"$id\">\n";
    
    echo "Event: " . $event->row[id] . "
    \n";
    echo "Type: " . $event->row[type] . "
    \n";
    echo "Time: " . $event->row[date] . " " . $event->row[time] . "
    \n";
    echo "Description: " . $event->row[description] . "
    \n";
    echo "Last Modified By: " . $event->row[creator] . "
    
    \n";
    
    $attendies = new Table($database, "select d.id as \"reference\", m.name as \"mem
    ber\", d.dkp from tbl_dkp d, tbl_member m where d.dkp > 0 and d.event='$id' and
    d.member=m.id order by m.name");
    $attendies->title="<center>attendies</center>";
    $attendies->tableopts="border=\"1\"";
    $attendies->addcommand("delete","viewevent.php?id=$id&delete_attendie=","\$this-
    >row[reference]");
    $attendies->display();
    
    echo "
    \n";
    $members = new Result($database, "select * from tbl_member where active='true' o
    rder by name");
    echo $webpage->selectstart("attendiename");
    $webpage->selectoption("attendiename","","--Select Member--");
    while ($members->fetcharray())
      $webpage->selectoption("attendiename",$members->row[id],$members->row[name]);
    echo $webpage->selectend() . " Member
    \n";
    echo $webpage->formtext("attendiedkp") . " DKP Awarded
    \n";
    echo $webpage->formsubmit("Add Attendie","addattendie") . "
    
    \n";
    
    $drops = new Table($database, "select d.id as \"reference\", m.name as \"member\
    ", d.dkp, d.note as \"item\" from tbl_member m, tbl_dkp d where d.dkp < 1 and d.
    event = $id and d.member=m.id order by m.name");
    $drops->title = "<center>drops</center>";
    $drops->tableopts = "border=\"1\"";
    $drops->addcommand("delete","viewevent.php?id=$id&delete_drop=","\$this->row[ref
    erence]");
    $drops->display();
    
    echo "
    \n";
    $drops = new Result($database,"select * from tbl_item order by name");
    echo $webpage->selectstart("dropitem");
    $webpage->selectoption("dropitem","","--Select Item--");
    while ($drops->fetcharray())
      $webpage->selectoption("dropitem",$drops->row[id],$drops->row[name]." (".$drop
    s->row[dkp]." dkp)");
    echo $webpage->selectend() . " Item
    \n";
    
    $members = new Result($database, "select * from tbl_member where active='true' o
    rder by name");
    echo $webpage->selectstart("dropmember");
    $webpage->selectoption("dropmember","","--Select Member--");
    while ($members->fetcharray())
      $webpage->selectoption("dropmember",$members->row[id],$members->row[name]);
    echo $webpage->selectend() . " Member Received
    \n";
    echo $webpage->formtext("dropvalue") . " Dkp value if different from listed.
    
    \n";
    echo $webpage->formsubmit("Add Drop","adddrop");
    
    echo "
    
    \nDetails
    \n<textarea name=\"results\" cols=80 rows=10>";
    echo $event->row[results];
    echo "</textarea>";
    echo "\n
    " . $webpage->formsubmit("Update Details","updatedetails");
    $webpage->formend();
    $webpage->end();
    The page itself looks something like this..

    http://img53.imageshack.us/img53/6052/dkpdn0.png

  5. #5
    E. Body
    Join Date
    Jun 2006
    Posts
    2,181
    BG Level
    7
    FFXIV Character
    Bro Teampill
    FFXIV Server
    Gilgamesh
    FFXI Server
    Ifrit

    Quote Originally Posted by Devek
    The page itself looks something like this..

    http://img53.imageshack.us/img53/6052/dkpdn0.png
    Pfft your code fails..

    "Attendies"



    It's "attendees." Always cracks me up when some of the smartest people on the planet make trivial spelling mistakes. Not coincidentally, people who can typically bang out code rapid-fire style have a hard time doing mundane crap, like driving a car.

    (yes, I'm just flipping you shit for the sake of flipping you shit. ^^)

    Anyway, here's a snippet that uses a form which contains a CheckedListBox control and a Button control. The CheckedListBox has fields populated with names at design time, btw.

    Code:
    Public Class Form1
    
        ' Declare a simple struct that defines a member.
        Public Structure member
            Public Name As String
            Public Points As Integer
        End Structure
    
        ' Use a generic list to store the collection of members.
        Private members As List(Of member)
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            ' On button click, loop through each member who's
            ' checked to receive a point.
            For Each name As String In CheckedListBox1.CheckedItems
                ' Now loop through the collection of members.
                For i As Integer = 0 To members.Count - 1
                    ' Create an instance locally of the member in the list.
                    Dim m As member = members(i)
                    ' Does this name match the one in the list box?
                    If m.Name = name Then
                        ' Yup, add a point.
                        m.Points += 1
                        ' Since VB is retarded and you can't get
                        ' a reference to the item in the collection,
                        ' you have to assign the local copy to the
                        ' current position in the collection for any
                        ' assignments to stick. Yay VB.Net. (O.o)
                        members(i) = m
                    End If
                Next
            Next
        End Sub
    
        Public Sub New()
    
            ' This call is required by the Windows Form Designer.
            InitializeComponent()
    
            ' Add any initialization after the InitializeComponent() call.
            members = New List(Of member)
    
            ' Add in a member. Obviously you'd want to read
            ' this in a from a file you have stored somewhere, 
            ' not modify the code itself all the time. This is
            ' done here for brevity.
            Dim m As member
            m.Name = "Homeslice"
            m.Points = 10
    
            members.Add(m)
    
        End Sub
    End Class
    Note the assignment comment. I dislike VB so I didn't bother to look through docs to see if there's actually a way to make an assignment directly to an item in a collection via indexing. If there is, then you could optimize it a little more that way. This is the gist of what you're trying to do, sans popping up a message box. Dunno why you'd want to do that, but populating a dialog with info before you commit would be trivial.

  6. #6
    Yoshi P
    Join Date
    Jul 2005
    Posts
    5,016
    BG Level
    8

    There's really no reason whatsoever to use VB.NET over C#.

  7. #7
    E. Body
    Join Date
    Jun 2006
    Posts
    2,181
    BG Level
    7
    FFXIV Character
    Bro Teampill
    FFXIV Server
    Gilgamesh
    FFXI Server
    Ifrit

    Quote Originally Posted by divisortheory
    There's really no reason whatsoever to use VB.NET over C#.
    Only one I can think of: sadomasochistic tendencies.

  8. #8
    Puppetmaster
    Join Date
    Oct 2006
    Posts
    58
    BG Level
    2

    Are var2/3 global? what type are they? Just from what you are showing in code isnt enough to know what is happening. If you are binding a list to the control, you might wanna try refreshing that binding. Other then that, I can only tell you to use C# instead, if only to make it more readable.

  9. #9
    Banned.

    Join Date
    Jul 2005
    Posts
    5,821
    BG Level
    8
    FFXI Server
    Sylph
    WoW Realm
    Arthas

    Quote Originally Posted by divisortheory
    There's really no reason whatsoever to use VB.NET over C#.
    I used VB.net because I was talking to Wade[from the windower site] and asked what he codes in, he told me VB.net, so I figured id give it a try. This was my first programming experience at all and really everything is self tought. I want to learn C++, I have bought books on it but the books are really shitty. It will start off easy enough, explain what everything does and is, then it will just jump to something completely over myhead, and explains nothing. Its just like "copy this code; CONGRATS YOU LEANRED C++" fuck that.

    Yes I'm aware this program is very sloppy, kinda made it was I went. I would figure out something new and be like "hmm that would be cool to put in"

    http://files.filefront.com/Sorcerar/;67 ... einfo.html

  10. #10
    Yoshi P
    Join Date
    Jul 2005
    Posts
    5,016
    BG Level
    8

    If you want ot learn C++, then even more reason to start with C#. For starters, C# and VB.NET are basically equivalent to each other. Like so equivalent that you could almost make a one-to-one mapping between the two languages.

    And C++ syntax has a lot in common with C# syntax, so it would help you more in that respect.

  11. #11
    Banned.

    Join Date
    Jul 2005
    Posts
    5,821
    BG Level
    8
    FFXI Server
    Sylph
    WoW Realm
    Arthas

    halp :<

  12. #12
    Salvage Bans
    Join Date
    Jun 2006
    Posts
    871
    BG Level
    5

    Maybe I didn\'t catch what a checklist is.. is it a ComboBox, a ListBox, CheckedListBox, or a ListView?

  13. #13
    Puppetmaster
    Join Date
    Oct 2006
    Posts
    58
    BG Level
    2

    Doesn't matter what kind of control since data binding works the same for all of them. Did you try rebinding the data after you modified the counter? You might wanna try doing that since it is an ASP.NET application.

Similar Threads

  1. Quick VB Express 2008 Question
    By SaviorSelf in forum General Discussion
    Replies: 5
    Last Post: 2009-11-20, 21:41
  2. Just got a question for you guys
    By Blackwar in forum General Discussion
    Replies: 3
    Last Post: 2004-08-06, 20:14