User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 17 of 24

Thread: VIsual Basic

  1. #1
    Regular Member
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VIsual Basic

    Hi there !
    I hope you guy who like Badminton also can help me in Visual Basic.
    I am a beginner in VB .NET and have a problem.

    My problem is :
    I want to create 4 buttons (or other control), but all the 4 must be in an array, so the names must be like these : cntl(0), cntl(1), cntl(2) and cntl(3).

    In VB6, I have no problem, because when I copy and paste the button (in design form), I will be askes, create in array or not. But in VB .NET, no question like that.
    When I change the name of the control in its property to cntl(0) or button(1) enz, I got an error message, something like 'invalid name'.
    So..... how to make the 4 buttons in an array ?

    Please help me guys !!!!!

    FYI : I use VB .NET Professional version 2003.

  2. #2
    Regular Member
    Join Date
    Sep 2002
    Location
    T.O.
    Posts
    2,096
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    i personally hate desining object arrays on those forms.

    Why not just generate the buttons at runtime?

  3. #3
    Regular Member
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Because I am new in VB .NET so I don't know how.
    BigRedLemon, will you let me know how to generate the buttons at runtime ?

    Thx.

  4. #4
    Regular Member
    Join Date
    Sep 2002
    Location
    T.O.
    Posts
    2,096
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    havent used MS compliers in awhile... is it server side or client side?

  5. #5
    Regular Member
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Originally posted by bigredlemon
    havent used MS compliers in awhile... is it server side or client side?
    Actually can be in server and client side.
    Can you explain in general ?

  6. #6
    Regular Member
    Join Date
    Sep 2002
    Location
    T.O.
    Posts
    2,096
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Is the complier on your local computer or on a server's computer?
    was is the file extension of your saved program?

  7. #7
    Regular Member
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Wauhhh......
    Let's make it simple Brl. I am new in VB .NET and still learning.

    I create a new project in VB .NET.
    I have a TextBox for enter a sentence that consist of max. 12 words and a button to get it starts.
    The program should create (a) button(s) as many as the words in the sentence.
    If the sentence consist of 5 words, so I got 5 buttons.
    If the sentence consist of 10 words, so I got 10 buttons.

    Just that Brl.

  8. #8
    Regular Member
    Join Date
    Sep 2002
    Location
    T.O.
    Posts
    2,096
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    different code is used depending on where the code is being compiled. The gist of it would be something like:
    Code:
    dim btnMyButtons(2) as array
    
    For n = 0 to 2
    dim btnMyButtons(n) as new System.Windows.Forms.Button()
    btnMyButtons(n).property1 = some value
    btnMyButtons(n).property2 = some value
    
    Next n
    The above code will not work, but you can reformat it with the right calls to make it work.

    Btw, i thought all buttons had to be declared as btnSomeName as standard coding procedure... its what microsoft recommends to make the code readable

  9. #9
    Regular Member
    Join Date
    Apr 2002
    Location
    Surrey, Canada
    Posts
    1,534
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    watch your FOR loop as it will exceed the array size.

  10. #10
    Regular Member
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Brl,
    I think we must write like this :

    dim btnMyButtons(2) as array
    For n = 0 to 1 Not --> for n = 0 to 2 (Thanks BadRad)
    dim btnMyButtons(n) as new System.Windows.Forms.Button()
    btnMyButtons(n).property1 = some value
    btnMyButtons(n).property2 = some value
    Next n

    But I have red an article that say : VB .NET doesn't support controls array.
    Does MyButtons(n) work ?

    Hier you can read the article.

  11. #11
    Regular Member
    Join Date
    Sep 2002
    Location
    T.O.
    Posts
    2,096
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Originally posted by badrad
    watch your FOR loop as it will exceed the array size.
    iirc array(2) makes an array or (0), (1), and (2).... I only have a java complier on this computer so i have no way of finding out for sure.... You can always declare a vector and not have to worry about array sizes.

  12. #12
    Regular Member
    Join Date
    Sep 2002
    Location
    T.O.
    Posts
    2,096
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    it doesn't even support control arrays?

    Have you considered C++?

  13. #13
    Regular Member
    Join Date
    Jan 2003
    Location
    TW
    Posts
    3,949
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Originally posted by bigredlemon
    it doesn't even support control arrays?

    Have you considered C++?
    Exactly, Microsoft is evil. C++ is definetely the way to go (with use of Linux or UNIX)

  14. #14
    Regular Member
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Originally posted by bigredlemon
    it doesn't even support control arrays?

    Have you considered C++?
    I stick to VB .NET
    I don't like C++, if I have to choose between C++ and C#.
    I will choose C#.
    Anyway....... my problem is in VB .NET.

  15. #15
    Regular Member
    Join Date
    Apr 2002
    Location
    Surrey, Canada
    Posts
    1,534
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Originally posted by bigredlemon
    iirc array(2) makes an array or (0), (1), and (2).... I only have a java complier on this computer so i have no way of finding out for sure.... You can always declare a vector and not have to worry about array sizes.
    vb6 does allow the upper boundary (ie array(2) - {0,1,2)), but depending on which version of vb.net it might not (certain beta releases which I played with did not allow it (array(2) - {0,1) 2 was not allowed and returned "IndexOutOfRangeException". I think the current version fixed it to be consistent with vb6.

  16. #16
    Regular Member
    Join Date
    Jul 2003
    Location
    Ontario, Canada
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Give you a short code for this. I suppose you have one TextBox(named txtSentence) and one Button(named Button1) in your main form.

    Eric

    ___________________________________________--

    Private btns() As Button

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim i As Integer
    Dim counter As Integer = 0
    Dim word() As String = txtSentence.Text.Split(" "c)

    For i = 0 To word.Length - 1
    If word(i).Trim <> "" Then
    ReDim Preserve btns(counter)
    btns(counter) = New Button()
    btns(counter).Text = word(i)
    btns(counter).Top = 200
    btns(counter).Width = 50
    btns(counter).Height = 20
    btns(counter).Left = 50 + (counter * 70)
    Me.Controls.Add(btns(counter))
    AddHandler btns(counter).Click, AddressOf ResponseButtonClick
    counter += 1
    End If
    Next

    End Sub

    Private Sub ResponseButtonClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
    MessageBox.Show(sender.text)
    End Sub

  17. #17
    Regular Member
    Join Date
    Sep 2002
    Location
    T.O.
    Posts
    2,096
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    then you have the same problem as before... a control array, which is not supported by his complier

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Replies: 0
    : 11-22-2011, 10:20 AM
  2. Basic grip or Adjusted basic grip for smashing
    By Crimz in forum Techniques / Training
    Replies: 24
    : 02-06-2010, 08:58 AM
  3. Training your Eyes - VISUAL FOCUS
    By wedgewenis in forum Techniques / Training
    Replies: 6
    : 11-08-2004, 02:08 PM
  4. gym lighting and visual adjusting
    By SystemicAnomaly in forum General Forum
    Replies: 13
    : 09-14-2004, 02:07 AM
  5. After so long, visual treat...
    By wilfredlgf in forum World Championships 2003
    Replies: 8
    : 08-04-2003, 03:27 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •