
trend
Avatar/Signature-
Posts
185 -
Joined
-
Last visited
trend's Achievements
Newbie (1/14)
0
Reputation
-
Awesome! Code works great. One thing though. My db query returns amount due (money) in string in format XX.XX or just XX (so not using ",") And I am not 100percent sure if (?) i need to replace the . with , .. Because code: Dim Coll As New Collection Public Structure Person Public Name As String Public Cash As Double End Structure Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim RetArray(0, 0) As String Dim InstanceOfPerson As Person Dim OrgArray(100, 1) As String OrgArray = LookupPendingAccounts("get") Dim x As Integer = 0 While OrgArray(x, 0) <> "" TextBox1.Text = TextBox1.Text & vbNewLine & OrgArray(x, 0) & " " & OrgArray(x, 1) x = x + 1 End While TextBox1.Text = TextBox1.Text & vbNewLine & "---------------" & vbNewLine 'Make a collection to hold all the people and add the totals. For i As Int16 = 0 To UBound(OrgArray, 1) If OrgArray(i, 0) <> "" Then With InstanceOfPerson .Name = OrgArray(i, 0) .Cash = CType(OrgArray(i, 1), Double) End With If Not ItemExistInCollection(InstanceOfPerson.Name) Then Coll.Add(InstanceOfPerson, InstanceOfPerson.Name) Else InstanceOfPerson = Coll(OrgArray(i, 0)) InstanceOfPerson.Cash = InstanceOfPerson.Cash + CType(OrgArray(i, 1), Double) Coll.Remove(InstanceOfPerson.Name) Coll.Add(InstanceOfPerson, InstanceOfPerson.Name) End If End If Next 'if where keep going to work with the collection all we have to do to loop tru then is For Each InstanceOfPerson In Coll ' Debug.WriteLine(InstanceOfPerson.Name & InstanceOfPerson.Cash) TextBox1.Text = TextBox1.Text & vbNewLine & InstanceOfPerson.Name & " " & InstanceOfPerson.Cash Next End Sub Private Function ItemExistInCollection(ByVal Item As String) As Boolean On Error Resume Next Dim Ret As Object Ret = Coll(Item) If Ret <> "" Then Return True End If Return False End Function Seems to handle the addition fine. (As soon as I changed int32 values to doubles ). What do you think? Do I really need to regex and replace the . with , then convert to int32? or is using a double just as fine? thanks sooo much for the help :) If I owe you anything , let me know thanks
-
Here is my Org Post.. Org I was going to use an Array, but some people said it would be easier done with a DataTable: Hello, I have an array returned with these fields: Name, AmountDue, TypeID, Description The array is (100,1) and string type My problem is.. Some of the people in the array are in there more than once.. (For example they get a bonus on top of their hourly pay). How can I get an array with each entry having a unique Name.. and where the AmountDue is the combination of all money owed to them? example: OrgArray(100,1) OrgArray(0,0) = "Jay" OrgArray(0,1) = "10.00" OrgArray(1,0) = "Jay" OrgArray(1,1) = "1.00" OrgArray(2,0) = "David" OrgArray(2,1) = "10.00" OrgArray(3,0) = "Erin" OrgArray(3,1) = "10.00" OrgArray(4,0) = "David" OrgArray(4,1) = "1.00" NewArray(100,1) should be something like: "Jay" = NewArray(0,0) "11.00" = NewArray(0,1) "David" = NewArray(1,0) "11.00" = NewArray(1,1) "Erin" = NewArray(2,0) "10.00" = NewArray(2,1) Any ideas? thanks
-
Hmm.. I will pay someone to write the vb.net code.. Because I am honestly lost :/
-
I am guessing.. I need to create a new array from the DT returns UNIQUE 'Names' And then from there.. loop through the array saying.. select all records where Name = Name(x) perhaps?
-
Code example please.. Because I am completely clueless on what you are saying to do :/ thanks :)
-
Hello, I have an array returned with these fields: Name, AmountDue, TypeID, Description The array is (100,1) and string type My problem is.. Some of the people in the array are in there more than once.. (For example they get a bonus on top of their hourly pay). How can I get an array with each entry having a unique Name.. and where the AmountDue is the combination of all money owed to them? example: OrgArray(100,1) OrgArray(0,0) = "Jay" OrgArray(0,1) = "10.00" OrgArray(1,0) = "Jay" OrgArray(1,1) = "1.00" OrgArray(2,0) = "David" OrgArray(2,1) = "10.00" OrgArray(3,0) = "Erin" OrgArray(3,1) = "10.00" OrgArray(4,0) = "David" OrgArray(4,1) = "1.00" NewArray(100,1) should be something like: "Jay" = NewArray(0,0) "11.00" = NewArray(0,1) "David" = NewArray(1,0) "11.00" = NewArray(1,1) "Erin" = NewArray(2,0) "10.00" = NewArray(2,1) Any ideas? thanks
-
Private Function test(ByVal SP As String, ByVal db As String) Dim SafeUsername As String = "whaetver" Dim SafePassword As String = "password" Dim PendingAccounts(,) As String Dim MyConnection As New OleDbConnection("Provider=SQLOLEDB.1;User Id=" & SafeUsername & ";Password=" & SafePassword & ";Initial Catalog=" & db & ";server=servername.com;Use Encryption for Data=False") Dim myCmd As New OleDb.OleDbCommand(SP) Dim myReader As OleDb.OleDbDataReader myCmd.Connection = MyConnection myCmd.CommandType = CommandType.StoredProcedure Try MyConnection.Open() myReader = myCmd.ExecuteReader() ' If myReader.Read Then '= True Then Dim X As Integer = 0 Do While myReader.Read() PendingAccounts(X, 0) = myReader.GetString(0) PendingAccounts(X, 1) = myReader.GetString(1) PendingAccounts(X, 2) = myReader.GetInt32(2).ToString PendingAccounts(X, 3) = myReader.GetString(3) X = X + 1 Loop 'End If myReader.Close() MyConnection.Close() Catch MsgBox( Err.Description) End Try TextBox1.Text = TextBox1.Text & "Done!" Return PendingAccounts End Function Yeah, you are right.. this function isn't working right.. my msgbox(err.description) is throwing a similiar error .. null references or something of the like.. Am I utilizing the array wrong? thanks!
-
I setup an array like: dim test(,) as string test = functionname("test") msgbox(test.length) and hten I get error: An unhandled exception of type 'System.NullReferenceException' occurred in Trigger v2.exe Additional information: Object reference not set to an instance of an object. Why? I know there are 10 or 20 some records that should be returned by functioname("test"). I have tried test.length(1).. and a lot of other test.* ones.. But seem to get the same errror above.. Why? thanks!
-
I have 1 form, with 2 sets of information: Billing Address <submit button> Credit Card Information <Submit Button> When a user presses the enter button after typing something, the first <submit button> is automatically used. How can I make it so.. if the user is typing in credit card info, and he hits enter.. the <submit button> for CC info will be submited instead of the other? thanks!
-
Are you kidding! That is it!! I have been beating my head for a wile on this problem.. what a nice solution :) thanks!
-
private function one() Dim words(50,2) as string Call two(word) end function Private Function two(byval two() as string) End Function That is essentially what I want to do.. but the problem arrises on how I accept a 2d array in a function.. aka like: private funtion two(byval two() as string) creates a problem.. So how do I pass 2d arrays to functions? thanks!
-
:) works great! thanks
-
Actually.. The date I am given should be on a friday... SO I just need to find out what the next friday's date is (here again problem is dealing with different month lengths)
-
I have a program that will give me a random date.. example: 5/1/2006 or 2/3/2003.. or whatever.. and I need to find the previous and next's friday's Date. I guess the big problem is month endings.. 29days, 30days.. 31days?? I am afraid all I know how to do right now is split(date,"/") to give me the day, month, year values.. Where do I go from here? thanks!
-
Anyone ? :(