Lan Solo Posted May 29, 2003 Posted May 29, 2003 Ok, my verbiage might not be right on the money (cuz I'm a Newbie) but let me try to explain. My school project requires that we declare a data table as a Global Integer Array. The form menu gives the user options to either sum or average the rows and columns and then display the results in a message box. I am having trouble determining the subs or variables that will be used when the click event occurs. Here is some code from the project. If anyone has any suggestions or can see where I am messing up, that would be great. I can't seem to get the desired results to display. Dim gintTable(,) = {{5, 7, 3, 9, 12}, {4, 8, 9, 13, 4}, {0, -1, -7, 13, 8}, {4, 4, 4, 4, 0}} Dim intRowSum As Integer Dim C As Integer Dim R As Integer Dim X As Integer Dim IntSum Dim strX As String Dim ControlChar Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub btnRowSum_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRowSum.Click For R = 0 To 3 For X = 1 To 4 For C = 0 To 4 IntSum += gintTable(R, C) Next C strX = IntSum Next X Next R End Sub R is for Row, C is for Column, X is the incremental variable I want to 'attach' to str, so each loop will generate a new total. So - One thing I cannot get it to do, my 'strX' is the 'Result' and the logic is failing. How do I get �strX� to 'hold' it's value each loop, and display in the MsgBox, noncumulative? (I wanted X to increase by 1 each loop and end up with 'str1, str2... or strX1, strX2...) Thanks in advance. Quote
Administrators PlausiblyDamp Posted May 30, 2003 Administrators Posted May 30, 2003 in vb you would use strX += IntSum ;) sorry couldn't resist Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
aewarnick Posted May 30, 2003 Posted May 30, 2003 I thought it was the same but I wanted to make sure. Now I know. Thank you. Quote C#
Administrators PlausiblyDamp Posted May 30, 2003 Administrators Posted May 30, 2003 VB doesn't get the ++ or -- operators though, and I do miss them. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
aewarnick Posted May 30, 2003 Posted May 30, 2003 It does use += to append to a string doesn't it? Quote C#
*Experts* Volte Posted May 31, 2003 *Experts* Posted May 31, 2003 It does use += to append to a string doesn't it? & and &= are the string appending operators. Quote
wyrd Posted May 31, 2003 Posted May 31, 2003 & and &= are the string appending operators. Maybe for VB, but for C# you use + for string concatenation. Maybe you can use both & and + in C#, but I know for a fact you can use +=. Quote Gamer extraordinaire. Programmer wannabe.
*Experts* Volte Posted May 31, 2003 *Experts* Posted May 31, 2003 Oh, heh, yeah. I thought you meant VB in comparison to C#, not other way around. If you're going to be doing any significant amount of string building, you should use the StringBuilder class (with it's .Append method) anyway. :p Quote
aewarnick Posted May 31, 2003 Posted May 31, 2003 I didn't know that VB did not use += for string concentation. Thanks. Quote C#
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.