PDA

View Full Version : Anyone know Visual Basic??



superfox1
08-28-2007, 09:44 PM
I am taking a VB class and have 3 assignments left. I am VERY lost and need some help...The teacher is no help what-so-ever.

So VB experts out there?

BiH1320
08-28-2007, 09:45 PM
nop sorry

Nemesis
08-28-2007, 09:47 PM
What do you need help with exactly, PM me if you want, but Ill try to answer it tommorrow while im at work..

superfox1
08-28-2007, 10:10 PM
Thanks man, PM sent

If you can solve the problems, I'll buy you a 12 pack of beer!:goodjob: Or Coke (if your a non drinker)

Ruiner
08-28-2007, 10:44 PM
I am taking a VB class and have 3 assignments left. I am VERY lost and need some help...The teacher is no help what-so-ever.

So VB experts out there?

Back in '98, I took a midterm VB test drunk as shit in college. It was Cinco De Mayo and I had forgotten that I had a test. I had 2 or 3 hours between classes, so my buddy and I hit the bars and pounded a few (too many). I showed up to the class (it was in Athens, so the bars are 100 yds from the North Campus Business classes).

I still got a 97 or 98, booyaaa! :)

RandomGuy
08-29-2007, 01:41 AM
yeah

<pm me if no one else comes thru

senior year in high school i placed 2nd place in the state in VB6 - out of 500 competitors (never messed with .net but i'm sure I could pick it up with ease) at some youth leadership conference (fbla bullshit) they flew me in to denver to compete at nationals.

Sol-Badguy
08-29-2007, 06:51 AM
I did back in High School.

I forgot it now. I haven't touched it in a few years.

superfox1
08-29-2007, 11:14 AM
yeah

<pm me if no one else comes thru

senior year in high school i placed 2nd place in the state in VB6 - out of 500 competitors (never messed with .net but i'm sure I could pick it up with ease) at some youth leadership conference (fbla bullshit) they flew me in to denver to compete at nationals.

sweet! Hell, in High School, I did the BASIC language...thats how old I am. I can do HTML all day long and I work with Linux boxes for a living, but can't figure this out...I got someone workingon it now, but I'll let you know

Ruiner
08-29-2007, 12:57 PM
sweet! Hell, in High School, I did the BASIC language...thats how old I am. I can do HTML all day long and I work with Linux boxes for a living, but can't figure this out...I got someone workingon it now, but I'll let you know

I remember using BASIC back in high school as well. Shit we ARE old. :rofl:

Hell, I remember back when I had TYPING class that were on actual type-writers. :lmfao:

4dmin
08-29-2007, 01:44 PM
i work w/ .net daily but i'm slammed man

superfox1
08-29-2007, 02:21 PM
I remember using BASIC back in high school as well. Shit we ARE old. :rofl:

Hell, I remember back when I had TYPING class that were on actual type-writers. :lmfao:


I remember that! During typing class, we would get to hop on the old 386's and play Oregon Trail on Fridays.

I learned to type from those classes..and will always remember "asdfghjkl;"

superfox1
08-29-2007, 02:23 PM
i work w/ .net daily but i'm slammed man

np!

This isn't .net...not sure what the difference is...hehe shows how much I know about it!

superfox1
08-29-2007, 06:03 PM
The first problem is I have written a program that will allow users to enter any number of rainfall amounts. I need it to calculate and display the total rainfall amount and the average rainfall amount. I have to break it down into 2 seperate functions.

This is what I have so far:

Option Explicit On
Option Strict On

Public Class MainForm

Private Function CalcAverage(ByRef raincounter As Integer, ByRef rainAccum As Integer, ByVal avgRain As Integer)
' Calculates average rainfall amount
avgRain = (rainAccum + raincounter) / 2

Return avgRain
Call CalcAverage(rainAccum, raincounter)
End Function


Private Function CalcTotal(ByVal rainCounter As Decimal, ByVal rainAccum As Decimal) As Decimal
' calculates the total
rainAccum = rainCounter + rainAccum



Return rainAccum

Call CalcTotal(rainCounter, rainAccum)

End Function



Private Sub xExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xExitButton.Click
Me.Close()
End Sub


Private Sub xMonthlyTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles xMonthlyTextBox.KeyPress
' accept numbers, the period, and the Backspace

If (e.KeyChar < "0" OrElse e.KeyChar > "9") _
AndAlso e.KeyChar <> "." AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub

Private Sub xMonthlyTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles xMonthlyTextBox.TextChanged
Me.xTotalLabel.Text = String.Empty
Me.xAverageLabel.Text = String.Empty
End Sub

Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub xCalcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xCalcButton.Click
Dim rainAccum As Decimal
Dim avgRain As Decimal

Me.xTotalLabel.Text = rainAccum.ToString("n2")
Me.xAverageLabel.Text = avgRain.ToString("n2")
End Sub
End Class






The next one I have to write a program that will allow users to enter in a 5 digit number with the 5th digit being the check digit. What needs to happen is the user enters in the 5 digit code...every other number is multiplied by 2...then add the numbers together, take the last digit and add it to the end of the first number set to check if it is the correct number...then I need it to display if it is correct or incorrect.

I know it sounds confusing..here is an example

Original number: 1357
multiply every other number by 2: 1 3 5 7
*2 *2
Results: 1 6 5 14

Add the numbers together: 1+6+5+14 = 26

new number: 13576
six would be my check digit.




Here is what I have so far:


Option Explicit On
Option Strict On

Public Class MainForm

Private Sub xExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xExitButton.Click
Me.Close()
End Sub

Private Sub xNumberTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles xNumberTextBox.Enter
Me.xNumberTextBox.SelectAll()
End Sub

Private Sub xNumberTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles xNumberTextBox.KeyPress
If (e.KeyChar < "0" OrElse e.KeyChar > "9") _
AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub

Private Sub xNumberTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles xNumberTextBox.TextChanged
Me.xMessageLabel.Text = String.Empty
End Sub

End Class

Jecht
08-29-2007, 06:12 PM
If you can't do anything with Visual Basic, I suggest you don't pursue a career related to computers.

RandomGuy
08-29-2007, 06:14 PM
The first problem is I have written a program that will allow users to enter any number of rainfall amounts. I need it to calculate and display the total rainfall amount and the average rainfall amount. I have to break it down into 2 seperate functions.

This is what I have so far:

Option Explicit On
Option Strict On

Public Class MainForm

Private Function CalcAverage(ByRef raincounter As Integer, ByRef rainAccum As Integer, ByVal avgRain As Integer)
' Calculates average rainfall amount
avgRain = (rainAccum + raincounter) / 2

Return avgRain
Call CalcAverage(rainAccum, raincounter)
End Function


Private Function CalcTotal(ByVal rainCounter As Decimal, ByVal rainAccum As Decimal) As Decimal
' calculates the total
rainAccum = rainCounter + rainAccum



Return rainAccum

Call CalcTotal(rainCounter, rainAccum)

End Function



Private Sub xExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xExitButton.Click
Me.Close()
End Sub


Private Sub xMonthlyTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles xMonthlyTextBox.KeyPress
' accept numbers, the period, and the Backspace

If (e.KeyChar < "0" OrElse e.KeyChar > "9") _
AndAlso e.KeyChar <> "." AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub

Private Sub xMonthlyTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles xMonthlyTextBox.TextChanged
Me.xTotalLabel.Text = String.Empty
Me.xAverageLabel.Text = String.Empty
End Sub

Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub xCalcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xCalcButton.Click
Dim rainAccum As Decimal
Dim avgRain As Decimal

Me.xTotalLabel.Text = rainAccum.ToString("n2")
Me.xAverageLabel.Text = avgRain.ToString("n2")
End Sub
End Class






The next one I have to write a program that will allow users to enter in a 5 digit number with the 5th digit being the check digit. What needs to happen is the user enters in the 5 digit code...every other number is multiplied by 2...then add the numbers together, take the last digit and add it to the end of the first number set to check if it is the correct number...then I need it to display if it is correct or incorrect.

I know it sounds confusing..here is an example

Original number: 1357
multiply every other number by 2: 1 3 5 7
*2 *2
Results: 1 6 5 14

Add the numbers together: 1+6+5+14 = 26

new number: 13576
six would be my check digit.




Here is what I have so far:


Option Explicit On
Option Strict On

Public Class MainForm

Private Sub xExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xExitButton.Click
Me.Close()
End Sub

Private Sub xNumberTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles xNumberTextBox.Enter
Me.xNumberTextBox.SelectAll()
End Sub

Private Sub xNumberTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles xNumberTextBox.KeyPress
If (e.KeyChar < "0" OrElse e.KeyChar > "9") _
AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub

Private Sub xNumberTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles xNumberTextBox.TextChanged
Me.xMessageLabel.Text = String.Empty
End Sub

End Class
i only read the top part, but to clarify

you are trying to make a prog that will calculate the total and average rainfall amounts right?

in this function:

Private Function CalcAverage(ByRef raincounter As Integer, ByRef rainAccum As Integer, ByVal avgRain As Integer)
' Calculates average rainfall amount
avgRain = (rainAccum + raincounter) / 2

Return avgRain
Call CalcAverage(rainAccum, raincounter)
End Function

its referring to rain counter (i'm assuming thats the total number of entries added, and rainaccum = (rain accumulated?)= ?

I don't know about you but an easier way to do it would be to use an array man.

It would make everything so much easier for you. I'm not going to do your homework for you man but its mad easy just learn it.

Heres some pseudo code to point you into the right direction

declare an array (for the amount of rain)
in the procedure for the button, make it store the contents of the input box into a new element of this array

for example, say you have ran this prog, it will store

rain(0) = 5
rain(1) = 10
rain(2) = 7

ok got it? then the index(which is the number in the parenthesis of the variable) + 1 = the total number of entries you added right?

so add up all of the elements of the array, and divide by (index + 1) of the variable.

theres the average.

to calculate the rainfall total, just simply add up all of the elements of the array

superfox1
08-29-2007, 09:16 PM
i only read the top part, but to clarify

you are trying to make a prog that will calculate the total and average rainfall amounts right?


I don't know about you but an easier way to do it would be to use an array man.

It would make everything so much easier for you. I'm not going to do your homework for you man but its mad easy just learn it.

Heres some pseudo code to point you into the right direction

declare an array (for the amount of rain)
in the procedure for the button, make it store the contents of the input box into a new element of this array


I cant do an array...not allowed.... have to do two seperate functions to calculate the total and average rainfall. I am completely lost. This is an online class and the teacher never answers any emails. Very frustrating. I got it all untill I got to this last part..now it is like I'm looking at a Chineese dictionary.

superfox1
08-29-2007, 09:20 PM
If you can't do anything with Visual Basic, I suggest you don't pursue a career related to computers.


Thank you for that well thought out response..actually I already have a very nice career in computers!
No VB needed!

I am a Networking Engineer and use Linux boxes all day. VB doesnt even come into my vocabulary.

I am not in school to get a degree, I already have one. I am going to school to get the rest of my GI BIll. It ends in December..this is the last set of classes I will take

RandomGuy
08-29-2007, 11:57 PM
The first problem is I have written a program that will allow users to enter any number of rainfall amounts. I need it to calculate and display the total rainfall amount and the average rainfall amount. I have to break it down into 2 seperate functions.



code seems like vb.net but still very similar
or your teacher is reallllly picky haha


hrm no arrays? haha ok still very doable
well first thing is that you mixed up your variable passing in the function (byref and byvals) when you pass a variable to a procedure with byref, you can fuck with the value and what not, but if you send it byval, then once you're out of the procedure then shit restores back to normal.


i'm assuming rainaccum is the value inputed
why not make a variable called avg1
also totalrain

try something along these lines:

Option Explicit On
Option Strict On

first thing first the variables: declare avg1, rainaccum, and totalrain and initialize 'em to 0.


Public Class MainForm

Private Function CalcAverage(ByVal rainaccum As Integer, ByRef avg1 As Integer)
' Calculates average rainfall amount
avg1 = (rainAccum + avg1) / 2 ((just get add the value of the entered info the the existing average, and then divide out, much like we do with grades haha)
Return avg1
Call CalcAverage(rainAccum, avg1) [why not call the function from the click event ... it doesnt specify what type of function was needed]
End Function
ok so now whenever you call calcaverage with those parameters, it'll take the current average, add the new value to it, then divide by two, giving you the current average

Private Function CalcTotal(ByRef TotalRain As Decimal, ByVal rainAccum As Decimal)
' calculates the total
totalrain = totalrain + rainAccum

Return totalrain

Call CalcTotal(totalrain, rainAccum)[same as above]

End Function



if u still aren't following:

make the procedure for the button pass the .text property of the textbox to the variable rainaccum

then in that sub, call calcaverage and pass rainaccum and avg1 to it
it'll calculate

then call calc total with totalrain and rain accum passed to it




after all thats done, in the sub for the click event on the button,
make it output the data however you do it
like label1.caption = aksldajsdk or whatever

and make it do what you want


but yeah Its late so i'm sure i overlooked something but yeah as for the second one it looks long i dont even feel like reading it