Nested For Loop to populate matrix

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • Killer42
    replied
    Originally posted by slvr02scooby
    ... Form and Design are nowhere to be found ... I know this is simple for some but man this program is frustrating lol
    From what I've heard, while there are undoubtedly improvements in the later versions, VB6 is much quicker and simpler to work with. It's a shame M$ had to make such a radical change of direction. :(

    The crazy thing is that schools all over the place are still teaching VB6, which is now well over ten years old and at least 3 or 4 versions behind the times.

    Leave a comment:


  • Killer42
    replied
    The original question asked for nested loops. Post #4 showed you're getting the idea. One technique which would work is to have the outer loop (let's say X) step by 5 at a time, and have the inner Y loop go from X to X + 4.

    It's important that you learn to understand and be comfortable with loops, including nested loops. They're a very important and heavily-used feature of the language.

    jamesd0142, I'd like to make two points. First, using an array seems somewhat over the top for such a simple task. And second, please remember that we don't hand out answers to homework questions (though helping to understand the problem is fine). Oh, and a third point I just thought of. What purpose does your array serve? How is using hold(i) any different to using i?

    Oh, and werks... I'm watching you too... ;)

    Leave a comment:


  • slvr02scooby
    replied
    Yeah I am using the express edition, it does make sub directories for them but it just says Your project currently has no data sources associated with it.

    Leave a comment:


  • kadghar
    replied
    Originally posted by slvr02scooby
    Correct. i'm not looking for any interaction, just for the window to show the table.

    Now i've run in to my next problem, after working on it last night i go to pull it up and while the project exsists, the Form and Design are nowhere to be found and I know I saved them both each time before trying to run it.

    I know this is simple for some but man this program is frustrating lol
    To be honest with you, i've never used vb2005 other than the express edition, but i think the Form should be saved in the same dir as the project, may be it creates a subdir called src or source... but it should be somewhere around there. Its extension is .frm

    Leave a comment:


  • slvr02scooby
    replied
    Correct. i'm not looking for any interaction, just for the window to show the table.

    Now i've run in to my next problem, after working on it last night i go to pull it up and while the project exsists, the Form and Design are nowhere to be found and I know I saved them both each time before trying to run it.

    I know this is simple for some but man this program is frustrating lol

    Leave a comment:


  • kadghar
    replied
    Originally posted by slvr02scooby
    Now if I don't use a text box then I would just need to put it in a msgbox instead fo rthe window to pop up correct?

    I'm using VB2005
    yeap, that's right, but remember you cannot select the text in a msgbox, nor copy it.

    Leave a comment:


  • slvr02scooby
    replied
    Now if I don't use a text box then I would just need to put it in a msgbox instead fo rthe window to pop up correct?

    I'm using VB2005

    Leave a comment:


  • kadghar
    replied
    Originally posted by jamesd0142
    im using vb 2005, but i find its the same as vb.net right?
    not always, and not for every version, most of the changes in .net and in express editions is that the mid, left and right functions are being replaced by the .substring property, also the Len function is replaced with the .lenght property.

    But, the main idea is well shown in the code, so i think the syntax problems shouldn't be so.

    Leave a comment:


  • werks
    replied
    Originally posted by jamesd0142
    im using vb 2005, but i find its the same as vb.net right?
    No idea im still in VB 6..


    --
    Kenneth
    "Better Than Yesterday"

    Leave a comment:


  • jamesd0142
    replied
    Originally posted by werks
    Are you using VB.Net?


    --
    Kenneth
    "Better Than Yesterday"
    im using vb 2005, but i find its the same as vb.net right?

    Leave a comment:


  • werks
    replied
    Originally posted by jamesd0142
    you need:

    textbox - textbox1
    button - button1

    [code=vbnet]
    Public Class Form1
    Dim i As Integer
    Dim a As Integer = 0
    Dim hold(49) As Integer

    Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
    Dim a As Integer = 0
    For i = 0 To 49
    hold(i) = i
    Next
    For i = 0 To 49
    a += 1
    TextBox1.Text = TextBox1.Text & hold(i) & " "
    If a = 5 Then
    TextBox1.Text = TextBox1.Text & vbCrLf
    a = 0
    End If
    Next
    TextBox1.Text = Mid(TextBox1.Te xt, 1, Len(TextBox1.Te xt) - 2)
    End Sub
    End Class
    [/code]

    Are you using VB.Net?


    --
    Kenneth
    "Better Than Yesterday"

    Leave a comment:


  • jamesd0142
    replied
    you need:

    textbox - textbox1
    button - button1

    [code=vbnet]
    Public Class Form1
    Dim i As Integer
    Dim a As Integer = 0
    Dim hold(49) As Integer

    Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
    Dim a As Integer = 0
    For i = 0 To 49
    hold(i) = i
    Next
    For i = 0 To 49
    a += 1
    TextBox1.Text = TextBox1.Text & hold(i) & " "
    If a = 5 Then
    TextBox1.Text = TextBox1.Text & vbCrLf
    a = 0
    End If
    Next
    TextBox1.Text = Mid(TextBox1.Te xt, 1, Len(TextBox1.Te xt) - 2)
    End Sub
    End Class
    [/code]
    Attached Files

    Leave a comment:


  • debasisdas
    replied
    Can you kindly post your code for reference of our experts please.

    Leave a comment:


  • slvr02scooby
    replied
    Sorry if my wording was misleading, i'm by no means looking for someone to tell me the answer, I've been attempting and had a much better understanding when I had my example but i don't anymore!

    What I have so far is stating

    Dim"name" as integer

    I know I need to create a For statement, so I need to use 2 variables such as "x" and "y", is it as simple as x= 0 to 49 and y= something like if x doesn't equal...then +1?

    Leave a comment:


  • werks
    replied
    I can only come up with this.. Just modify it..

    [CODE=vb 6]
    Private Sub cmdGenerate_Cli ck()
    Dim i As Integer
    Dim j As Integer
    j = 0
    For i = 0 To 49
    j = j + 1
    If j = 5 Then
    j = 1
    Print vbCrLf
    Print i
    Else
    Print i
    End If
    Next
    End Sub

    Private Sub Form_Load()
    Form1.WindowSta te = 2
    End Sub

    [/CODE]


    -Kenneth
    -"Better Than Yesterday"

    Leave a comment:

Working...