Do my vb.net homework for me. Nao.

Do my vb.net homework for me. Nao.

Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
So, we've got this assignment in my vb.net class that is stumping me. It's still pretty early in the class, so I'm sure the solution is pretty simple, which means I'm most likely over-thinking it.


Anyways, what we are supposed to do is create a block of code using for...next statements that will output the following:
code
*
**
***
****
*****
******
*******
********
*********
**********



For whatever reason, I can't think through the problem without if...else statements popping into my head, and can't really figure out how to do it with just for...next loops.

Any ideas?
 
 
 
2012 Feb 13 at 20:15 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
If I remember correctly, everything in the for loop gets executed,then when the for loop is completely finished it goes to next.

Let me see if I can't whip up something. Does it have a limit like the picture? or does it continue indefinitely.
 
 
 
2012 Feb 13 at 20:43 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
Would this work for you?
code
for($i=1;$i<=10;$i++) // this would go through our rows
{
for($p=1;$p<=$i;$p++) // add elements to our rows
{
echo "*";
}
next
{
echo "/n/r"; // print out a linebreak -unix
}
}
next
{
exit();
}

I'd think that would work, but of course you would write it in vb not php :P
 
 
 
2012 Feb 13 at 20:53 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
It's a definite amount. There's 10 rows, and there needs to be the same amount of asterisks per row as the row number (1 asterisk in row 1, 2 in row 2, etc).


I'll translate that to vb and see if it'll work, but I have a feeling it won't... just doesn't seem right.
I could definitely be wrong though, so I'll try it here in a few and post back with results.
 
 
 
2012 Feb 13 at 21:42 UTC
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
57,583 ₧
 
 
 
2012 Feb 13 at 22:40 UTC
SRAW
Rocket Man

2007 Nov 6 • 2525
601 ₧
I just tried it... sprinkles one DIDNT work, oh my god.
anyway this sorta works
code
#include <stdio.h>
#include <stdlib.h>

int main()
{
int i,n;
for(i=1,n=0;i<11;i++)
{
n=0;
for(;n<i;n++)
{
printf("*");
}
printf("\n");
}
}
Free Steam Games
 
 
 
2012 Feb 13 at 23:03 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
Down Rodeo said:
What the hell is for...next?

link



@SRAW - That looks like it should work, I'll convert it to VB and give it a whirl :D
 
 
 
2012 Feb 13 at 23:25 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
Alright, I got it to work. Here's what I used, just in case anyone is interested:
code
For counter1 As Integer = 1 To 10 Step 1
For counter2 As Integer = 1 To counter1 Step 1
TextBox1.AppendText("*")
Next
TextBox1.AppendText(vbCrLf)
Next




Sooo... now on to the next part. I'm actually supposed to make four different patterns, not just one. They are as follows:
code
*
**
***
****
*****
******
*******
********
*********
**********

code
**********
*********
********
*******
******
*****
****
***
**
*

code
*
**
***
****
*****
******
*******
********
*********
**********

code
**********
*********
********
*******
******
*****
****
***
**
*




The second one should be no problem... just do the same as the first solution, only count backwards from 10 to 1 instead of forwards from 1 to 10.
The last two, I haven't thought about how to do, but I should be able to figure 'em out now that I've got the solution for the first one :D
 
 
 
2012 Feb 13 at 23:58 UTC — Ed. 2012 Feb 14 at 00:00 UTC
SRAW
Rocket Man

2007 Nov 6 • 2525
601 ₧
what weird ass programming language is that?
Free Steam Games
 
 
 
2012 Feb 14 at 00:12 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
SRAW said:
what weird ass programming language is that?

vb.net


Also, I got the second one done:
code
For counter1 As Integer = 10 To 1 Step -1
For counter2 As Integer = counter1 To 1 Step -1
TextBox1.AppendText("*")
Next
TextBox1.AppendText(vbCrLf)
Next



Now on to 3 and 4...
 
 
 
2012 Feb 14 at 00:13 UTC
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
57,583 ₧
code
For counter1 As Integer = 10 To 1 Step -1
For counter2 As Integer = counter1 To 1 Step -1
TextBox1.AppendText("*")
Next
TextBox1.AppendText(vbCrLf)
Next


Ewww, vb.net. That's really nasty. These programs are funny :D
 
 
 
2012 Feb 14 at 01:11 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
Down Rodeo said:
Ewww, vb.net. That's really nasty. These programs are funny :D

I couldn't imagine coding without brackets and semicolons. So unorganized. D:
 
 
 
2012 Feb 14 at 01:40 UTC
SRAW
Rocket Man

2007 Nov 6 • 2525
601 ₧
number 3 and 4 looks like the other ones, except you put a space instead of the * and instead of a newline put a * and a newline

and vb.net is homosexual, autoit3 is way more pretty
Free Steam Games
 
 
 
2012 Feb 14 at 01:48 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
SRAW said:
number 3 and 4 looks like the other ones, except you put a space instead of the * and instead of a newline put a * and a newline

and vb.net is homosexual, autoit3 is way more pretty

Well, it's going to be a little more complicated than that, because I can't just append an asterisk to the end of each line... the amount of asterisks will have to increase/decrease as well. But that's easy enough, I just need to add one more for loop before I do the line break :D


And I agree, vb.net is a pile of dog shit... well, it's actually pretty useful for if you want to mock up a quick program really quick. But, as you guys pointed out, the format of everything is horrible... I much prefer C++ (not that I know it that well... but, I do like its' format a lot more :D).

Anyway, the class I'm taking is less about learning vb.net, and more about learning how to solve different problems in the programming world. And, because vb.net is a relatively easy language to learn, that's the one they're using to teach the class with (That way it's not a requirement to know some language like C or java in order to take the class).






Edit: Just out of curiosity, for those of you that have taken college level programming courses... do your professors tend to like when you comment your code in extreme detail, or do they tend to prefer if you keep it short and simple? I've been commenting the shit outta my code so I can prove I actually know what's going on, rather than just copy/pasta'ing the code from somewhere, but I don't know if my professor is going to be happy when he sees that my comments are like 4 times the length of the code itself xD

I suppose I could just ask him the next time I'm in class...
 
 
 
2012 Feb 14 at 01:55 UTC — Ed. 2012 Feb 14 at 01:58 UTC
the_cloud_system
polly pushy pants

2008 Aug 1 • 3081
-6 ₧
he masturbates vigorously to your comments.
I drink to forget but I always remember.
 
 
 
2012 Feb 14 at 02:20 UTC
cloud_the_system

2010 Sep 17 • 51
the_cloud_system said:
he masturbates vigorously to your comments.

omg my penii exploded!!1111
we can't stop here, this is bat country!
 
 
 
2012 Feb 14 at 02:40 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
I doubt anyone is really that interested, but here are the solutions I came up with for the last two:
code
For counter1 As Integer = 10 To 1 Step -1
For counter2 As Integer = counter1 To 1 Step -1
TextBox1.AppendText(" ")
Next
For counter3 As Integer = (11 - counter1) To 1 Step -1
TextBox1.AppendText("*")
Next
TextBox1.AppendText(vbCrLf)
Next

code
For counter1 As Integer = 1 To 10 Step 1
For counter2 As Integer = 1 To counter1 Step 1
TextBox1.AppendText(" ")
Next
For counter3 As Integer = 1 To (11 - counter1) Step 1
TextBox1.AppendText("*")
Next
TextBox1.AppendText(vbCrLf)
Next



I'm just gonna go ahead and comment the shit outta everything. If he doesn't want to read it, he doesn't have to, and it helps me to remember exactly why I did certain things... especially if I have to go back and re-use any of this code.
 
 
 
2012 Feb 14 at 02:43 UTC
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
57,583 ₧
sprinkles said:
Down Rodeo said:
Ewww, vb.net. That's really nasty. These programs are funny :D

I couldn't imagine coding without brackets and semicolons. So unorganized. D:

I somewhat agree but Python's really nice.

Yes, I would comment everything. Make sure they're useful comments though;
code
//increment x
x++;


is not considered clever.
 
 
 
2012 Feb 14 at 20:19 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
I think my comments are good enough... here's my complete code for that project, with comments:
VB code
Public Class Form1

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


For counter1 As Integer = 1 To 10 Step 1 'Increments counter1 by 1 for every time the process loops, starting at 1, and ending at 10. This is to create 10 lines in the textbox.
For counter2 As Integer = 1 To counter1 Step 1 'Increments counter2 by 1 for every time the process loops, starting at 1, and ending when the value of counter1 is reached. This is so that the number of astericks per line will increase at a uniform rate when compared to the line number (counter1).
TextBox1.AppendText("*") 'Appends an asterick to textbox1
Next
TextBox1.AppendText(vbCrLf) 'Appends a line break to textbox1
Next


For counter1 As Integer = 10 To 1 Step -1 'Decrements counter1 by 1 for every time the process loops, starting at 10, and ending at 1.
For counter2 As Integer = counter1 To 1 Step -1 'Decrements counter2 by 1 for every time the process loops, starting at the value of counter1, and ending when the value of 1 is reached. This is so that the number of astericks per line will decrease at a uniform rate when compared to the line number (counter1).
TextBox1.AppendText("*") 'Appends an asterick to textbox1
Next
TextBox1.AppendText(vbCrLf) 'Appends a line break to textbox1
Next


For counter1 As Integer = 10 To 1 Step -1 'Decrements counter1 by 1 for every time the process loops, starting at 10, and ending at 1.
For counter2 As Integer = counter1 To 1 Step -1 'Decrements counter2 by 1 for every time the process loops, starting at the value of counter1, and ending when the value of 1 is reached. This is so that the number of spaces per line will decrease at a uniform rate when compared to the line number (counter1).
TextBox1.AppendText(" ") 'Appends a space to textbox1
Next
For counter3 As Integer = (11 - counter1) To 1 Step -1 'Decrements the value of counter3 by 1 for every time the process loops, starting at the value of 11 minus the current value of counter1, and ending when the value of 1 is reached. This is so that the number of astrisks added after the spaces will scale apropriately to create the desired pattern.
TextBox1.AppendText("*") 'Appends an asterick to textbox1
Next
TextBox1.AppendText(vbCrLf) 'Appends a line break to textbox1
Next


For counter1 As Integer = 1 To 10 Step 1 'Increments counter1 by 1 for every time the process loops, starting at 1, and ending at 10. This is to create 10 lines in the textbox.
For counter2 As Integer = 1 To counter1 Step 1 'Increments counter2 by 1 for every time the process loops, starting at 1, and ending when the value of counter1 is reached. This is so that the number of spaces per line will increase at a uniform rate when compared to the line number (counter1).
TextBox1.AppendText(" ") 'Appends a space to textbox1
Next
For counter3 As Integer = 1 To (11 - counter1) Step 1 'Decrements the value of counter3 by 1 for every time the process loops, starting at the value of 11 minus the current value of counter1, and ending when the value of 1 is reached. This is so that the number of astrisks added after the spaces will scale apropriately to create the desired pattern.
TextBox1.AppendText("*") 'Appends an asterick to textbox1
Next
TextBox1.AppendText(vbCrLf) 'Appends a line break to textbox1
Next


End Sub
End Class
 
 
 
2012 Feb 14 at 21:58 UTC
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
57,583 ₧
Since I feel you ought to be learning things which you don't seem to be in this class, can you tell me the difference between ++x and x++?

EDIT: as in, I'm asking this like a teacher would.
 
 
 
2012 Feb 15 at 01:15 UTC — Ed. 2012 Feb 15 at 01:15 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
Down Rodeo said:
Since I feel you ought to be learning things which you don't seem to be in this class, can you tell me the difference between ++x and x++?

EDIT: as in, I'm asking this like a teacher would.

I had to Google it, cuz I didn't know, but I found the answer :D

The first one would increment x, then return the value of x after it's been incremented. The second one would return the value of x, and then increment it.

I guess it's worth nothing, we haven't used anything like that in vb.net yet (to my knowledge, you'd have to do something along the lines of "x += 1", though I could be wrong on that).


As I'm typing this though, I do vaguely remember using an incremental operator like that when I was dabbling in C++.
 
 
 
2012 Feb 15 at 01:33 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
Down Rodeo said:
++x and x++?

That's useful, thanks.
 
 
 
2012 Feb 15 at 03:06 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
sprinkles said:
Down Rodeo said:
++x and x++?

That's useful, thanks.

Indeed.
Give me more stuff like this DR... pretty please? :D
 
 
 
2012 Feb 15 at 03:12 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
Can anyone tell me what this operator does?
code
^=

I tried searching it on google and bing, but they seem to 'break' when I do...


Bitwise XOR assignment
 
 
 
2012 Feb 15 at 03:21 UTC — Ed. 2012 Feb 15 at 03:22 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
sprinkles said:
Can anyone tell me what this operator does?
code
^=

I tried searching it on google and bing, but they seem to 'break' when I do...


Bitwise XOR assignment

a ^= b
would be the same as
a = a ^ b


You can use other mathematical operators in the same way... for example:
c *= 4
is the same as
c = c * 4
 
 
 
2012 Feb 15 at 03:31 UTC
Page [1] 2 3