Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

Jumping Jupiter

@Jumping Jupiter
About
Posts
3
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Compare data of the last day with the past 4 day’s data
    J Jumping Jupiter

    I assume that your are quite new to VB.net but I may be wrong. I have therfore written the attached code using an array as you asked. I would not say it is the best method but if you are learning they I thought it better. Create a new project with a form1 and two listboxes (ListBox1 and ListBox2) Replace the code from your form with the attached code. It automatically generates test data to show you it working. It may not be exactly what you want but its a start.

    Public Class Form1

    Const NumberOfDaystocountBack = 4 'This is a constant for the number of dats you will count back
    Dim OriginalDataArray(15, 5) As String 'This is a sample array with 15 records each with 5 pieces of data
    Dim ResultsArray(1, 1) As String 'This is a sample array that will store the data, it is resized with the code

    Private Sub Main()
    'Generate test data
    Dim X As Integer
    Dim Y As Integer
    Dim TempString As String
    For X = 15 To 0 Step -1
    TempString = ""
    For Y = 0 To 4
    OriginalDataArray(X, Y) = Int(Rnd() * 10)
    TempString = TempString & OriginalDataArray(X, Y).ToString & ", "
    Next
    ListBox1.Items.Add(TempString)
    Next

    GenerateResults()
    
    For X = 15 To 0 Step -1
      TempString = ""
      For Y = 0 To 3
    
        TempString = TempString & ResultsArray(X, Y).ToString & ", "
      Next
      ListBox2.Items.Add(TempString)
    Next
    

    End Sub

    Private Sub GenerateResults()
    Dim MaxDayCount As Long
    Dim LoopCounter As Integer
    Dim RecordLoopCounter As Long
    Dim DataLoopCounter As Long
    Dim DataCount As Integer 'count of the number of data elements

    Dim TempArray1() As Integer
    Dim TempArray2() As Integer
    
    DataCount = OriginalDataArray.GetUpperBound(1) 'This will be '5' for the sample array given
    MaxDayCount = OriginalDataArray.GetUpperBound(0)  'This would be 50 for the sample array given
    
    ReDim ResultsArray(MaxDayCount, NumberOfDaystocountBack) 'Resize the results array to accept data
    
    
    For RecordLoopCounter = MaxDayCount To 0 Step -1 'Steps back through records of data
    
      'Pass the two days data to the comparison function
      For DataLoopCounter = 1 To NumberOfDaystocountBack
    
        ReDim TempArray1(DataCount) 'Resize array to the number of data elements and clears data
        ReDim TempArray2(DataCount) 'Resize array to the number of data elements and clears data
        If RecordLoopCounter - DataLoopCounter >= 0 Then
    
    Visual Basic help database

  • Compare data of the last day with the past 4 day’s data
    J Jumping Jupiter

    What version of visual basic are you using VB6, VB.net or another? The code will be slightly different in the way you access the listbox depending on the version.

    Visual Basic help database

  • Considering a career change. Any suggestions?
    J Jumping Jupiter

    I am in almost the exact same situation. I looked into going into teaching. The pay is so bad and it takes so long to climb up the ladder to a decent pay scale that its just not worth it. :omg:

    The Lounge question career learning csharp c++
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups