I'm a bit confused by your code, and some of the terms you use.
Dim j As Integer
For j = 0 To i - 1
If myArray(j) = jIn Then
MessageBox.Show ("Value is there")
u = 0
Exit Try
End If
this is the portion of the code searching the array, right? I should...
User Profile
Collapse
-
Need Help searching array
the program runs, and user is prompted via inputbox to enter an integer-this is the size of the array, then the user fills the array with that many values...but as the user enters the values, i need to check and make sure that none of hte values have already been entered in the array, if it has..then there must be a message telling user to enter a new value.
EX: user prompted to enter an integer e.g.-2, then user is prompted to enter... -
I'm not sure if i'm atucally populating the array, or it's jsut keeping the last value put into it. I tried the redim preserve keywords, but if i click the average button, it only gives me the average using the last grade entered,, not the sum of all of them. : here is my code for it:
Code:Public Class btnAdd Dim grades() As Double Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Leave a comment:
-
average with items in an array
I have an array, populated with student grades. there is a list of student names, but their grades are stored in a class level array. there is a calculate average button,that is supposed to calculate the grades in the array. But my button only returns the last grade that was entered, not the average, here is my code:
Code:public Class btnAdd Dim grades() As Double Private Sub Button1_Click(ByVal sender
-
need help populating array
i need to populate an array with grades. there is an 'add students & grades' button. user is prompted by input box to enter a students name, then another input box to enter their grade. the student's name is displayed in a list box. but the grades need to be stored in an array. here is a portion of my code:
Code:Public Class btnAdd Dim grades() As Double Private Sub Button1_Click(ByVal sender As System.Object,
-
thanks. I did try that code and it helped greatly. Although, I did create it as a function, i was required to. i just returned a message box with the string list.
If i wanted to eliminate just the listbox of the grades (not the student names) from the interface, and store the grades into an array, then use the array in the functions,
I'm just lookin for adivce on how to start.for example.. in my current code i have:
...Leave a comment:
-
displaying listbox items
I'm stuck on separately dispalying certain items from two different list boxes. student names and grades. For example one list box has names, and a list box next to it displays corresponding grade: sally 90
mike 80
etc..
there is a button, prompting user to enter a certain grade (through... -
there would be two list boxes with names and grades: ex sally 90
mike 85
i click the getbelowgrade button, and am prompted to enter a grade, say 88. it should display Mike's name (he's below 88), but it crashes and highlights the Return line of the function, saying value 88 is not valid for index.
I'm stuck, here is my the portion...Leave a comment:
-
I changed it to this. but it says "onegrade" and "i" are used before they are assigned a value and could result in a null reference exception. Does that not matter?
i changed it to a string and it still crashes.
Function GetBelowGrade() As Double
Dim onegrade As String
Do While Not IsPositiveNumbe r(onegrade)
onegrade = InputBox("pleas e enter a positive number...Leave a comment:
-
Thanks a lot, that helped. I also am having trouble with one other aspect. once the names and grades are displayed (in separate list boxes), there is a button, prompting the user to a certain grade, I must display a message box listing all of the student names below that certain grade. I've looped it to ask the user/ validate input, but it crashes before displaying the message box with all the names. Any thoughts? Here is a portion of my code: ...Leave a comment:
-
need help with listbox items
I am trying to calculate the class average of student's grades. the student names are displayed in a list box, while their corresponding grade is displayed in a separate list box. calculate the average: # of students/ sum of their grades.(grades are numeric)
EX: John 90
sally 88
mike 75
I can't get it to add the sum of the grades i.e. (90+88+75). Also, I... -
yeah, the txtbox names are all correct. Every other part of the calculator works properly. maybe i'm not calling it correctly, and i have changed the parameters to "as integers" , but still it crashes and hightlights the code of which ever txtbox i put the letter into. and says "conversion from string "e" to type double is not valid"
here's the function now, and how i've called it:
...Leave a comment:
-
i dont get an error message, the program just crashes and highlights the code : num1=txtnum1.te xt, or which ever text box i put the letter into. this is my function:
public Class Form1
Function checknumber(ByV al num1 As String, ByVal num2 As String) As Boolean
If Not IsNumeric(num1) Then
MsgBox("Input must be a number.")
ElseIf Not IsNumeric(num2) Then
...Leave a comment:
-
the rest of the calculator works, but when i type a letter into either of the textboxes and try to calculate it, the program crashes. I have no idea why this happens. the code looks fine to me. i need it to validate that the inputs are numbers but it just crahses.Leave a comment:
-
don't functions have to return a value? besides, one of the requirements is that i return a value indicating there was a problem...Leave a comment:
-
i did attempt it myself, where do you think all that code came from. i only asked about the user defined function validating the input as a number....Leave a comment:
-
need help with VB 08 Calculator
I need to create a calculator using combo boxes/procedures/functions etc... and some other stuff. most of it works properly, but, i need to create a user defined function that checks if both input numbers of the calculation are in fact numbers (isnumeric). the function must check both numbers, display a message box and return a value. but it crashes every time i test it - like putting in a letter instead of a number. any help would be great,
... -
VB 08 Calculator
i have to make a calculator in visual basic, it's slightly more complex one, using a combo box/procedures/functions. Anyway, i need to create a user defined function to make sure both input numbers (of the the calculation) are in fact numbers, the isnumeric function. both numbers have to be checked in the same function, and i must return a msgbox (as part of the function) displaying an error and return a value indicating there was a problem. it...
No activity results to display
Show More
Leave a comment: