Click here to Skip to main content
14,492,143 members

Visual Basic

 
AnswerRe: How can I get an free installer that registers .dll and .ocx components as I install my app? Pin
CHill6010-Dec-19 1:44
mveCHill6010-Dec-19 1:44 
AnswerRe: How can I get an free installer that registers .dll and .ocx components as I install my app? Pin
gvidali7-Feb-20 3:09
Membergvidali7-Feb-20 3:09 
Question[Solved] - How to retrieve value inserted to variable Pin
nrdroque5-Dec-19 23:26
Membernrdroque5-Dec-19 23:26 
AnswerRe: How to retrieve value inserted to variable Pin
lw@zi 6-Dec-19 0:41
professional lw@zi 6-Dec-19 0:41 
AnswerRe: How to retrieve value inserted to variable Pin
Richard Deeming6-Dec-19 1:05
mveRichard Deeming6-Dec-19 1:05 
GeneralRe: How to retrieve value inserted to variable Pin
nrdroque6-Dec-19 3:40
Membernrdroque6-Dec-19 3:40 
GeneralRe: How to retrieve value inserted to variable Pin
Eddy Vluggen6-Dec-19 8:49
professionalEddy Vluggen6-Dec-19 8:49 
QuestionMS Chart is adding extra X axis when doing multiple series. Pin
Member 1435926026-Nov-19 8:31
MemberMember 1435926026-Nov-19 8:31 
Ms Chart is a pain in the behind, first I had an issue where when binding or manually adding dates to my X axis it would force add every single date in between even though that data didn't exist, my SQL code is setup with a date dimension table which makes it so I only return exactly the number of rows I want (4 weeks 4 values, 5 months, 5 values)

"Fixed" that by instead adding generic counter for X axis and then setting the label to the date, or so I thought...


[Now that I've added code to do multiple series the damn thing is adding extra items to the X axis again]

[The dates in each series are exactly the same.]

My counter gets reset to 0 before every series and when I loop through the code to see the data points in debug the labels and data are set properly for every series. but ms chart still decides it needs 12 billion extra lines on the X axis for no goddamn explainable reason.

Private Sub LoadChart()

        Dim oDT As New DataTable
        Dim sqlCmd As New SqlCommand

        Dim sSQLDateCTE As String = "WITH Date_CTE as ( " & _
                "SELECT {0} DDim.[Date] as SaleDate " & _
                "FROM [DateDimension] as DDim {1} "
        Dim sWHEREDateCTE As String = "WHERE [Date] BETWEEN DATEADD({0},-{1},GETDATE()) AND GETDATE() {2} "
        Dim sSQLSUM As String = "), SUM_CTE as ( " & _
                "SELECT {0}" & _
                "FROM {1} " & _
                "WHERE F1034 = 3 AND F64 <> 0 AND F01 = @UPCCode " & _
                "AND F254 IN (SELECT saledate FROM Date_CTE) " & _
                "GROUP BY {2}) "
        Dim sSQLFinalPart = "SELECT {0} DC.SaleDate ,ISNULL(SC.UnitsSold,0) as UnitsSold " & _
                "FROM Date_CTE as DC " & _
                "LEFT OUTER JOIN SUM_CTE as SC " & _
                "ON SC.SaleDate = DC.SaleDate {1}" & _
                "ORDER BY DC.SaleDate ASC "


        Dim sFieldList As String = ""
        Dim sGroupBy As String = ""
        Dim sStorelist As String = ""

        Dim sWhereIN As String = ""
        Dim sWhereINDateCTE As String = ""

        Dim sSQL As String = ""

        Try

            If oAppEnv.sSource = "H" Then
                For Each CheckedItem In clbStores.CheckedItems
                    If sStorelist <> "" Then
                        sStorelist = sStorelist & ", "
                    End If
                    sStorelist = sStorelist & CheckedItem.key
                Next
            End If

            If sStorelist <> "" Then
                sFieldList = "F01 as UPCCode, F1056 as Store, F254 as SaleDate, SUM(F64) as UnitsSold "
                sGroupBy = "F01,F1056,F254"
                sSQLDateCTE = String.Format(sSQLDateCTE, "SL.Store, ", "CROSS JOIN Newbuck.dbo.tblStoreList as SL ")
                sWhereIN = "AND {0} in ({1}) "
                sWhereINDateCTE = String.Format(sWhereIN, "SL.Store", sStorelist)
                sSQLFinalPart = String.Format(sSQLFinalPart, "DC.Store, ", "AND SC.Store = DC.Store ")
            Else
                sFieldList = "F01 as UPCCode, F254 as SaleDate, SUM(F64) as UnitsSold "
                sGroupBy = "F01,F254"
                sSQLDateCTE = String.Format(sSQLDateCTE, "", "")
                sWhereINDateCTE = ""
                sSQLFinalPart = String.Format(sSQLFinalPart, "", "")

            End If


            Dim PeriodRow As DataRow = oAppEnv.dtPeriods.Select(String.Format("DPPeriodID = {0}", cboPeriods.SelectedValue)).FirstOrDefault

            Dim DurationRow As DataRow = oAppEnv.dtDurations.Select(String.Format("DDDurationID = '{0}'", cboDuration.SelectedValue)).FirstOrDefault

            Select Case PeriodRow.Item("DPPeriodAbbrev")
                Case "D"
                    sWHEREDateCTE = String.Format(sWHEREDateCTE, "DD", DurationRow.Item("DDDurationLength"), sWhereINDateCTE)
                    sSQLSUM = String.Format(sSQLSUM, sFieldList, "RPT_ITM_D", sGroupBy)
                    sSQL = sSQLDateCTE & sWHEREDateCTE & sSQLSUM & sSQLFinalPart
                Case "W"
                    sWHEREDateCTE = String.Format(sWHEREDateCTE, "WW", DurationRow.Item("DDDurationLength"), sWhereINDateCTE) & " AND Weekday = 1 "
                    sSQLSUM = String.Format(sSQLSUM, sFieldList, "RPT_ITM_W", sGroupBy)
                    sSQL = sSQLDateCTE & sWHEREDateCTE & sSQLSUM & sSQLFinalPart
                Case "M"
                    sWHEREDateCTE = String.Format(sWHEREDateCTE, "MM", DurationRow.Item("DDDurationLength"), sWhereINDateCTE) & " AND [DAY] = DATEPART(Day,getdate()) "
                    sSQLSUM = String.Format(sSQLSUM, sFieldList, "RPT_ITM_M", sGroupBy)
                    sSQL = sSQLDateCTE & sWHEREDateCTE & sSQLSUM & sSQLFinalPart
                Case "Y"
                    sWHEREDateCTE = String.Format("WHERE [Date] BETWEEN '01-01-2009' AND GETDATE() AND DayOfYear = 1 {0} ", sWhereINDateCTE)
                    sSQLSUM = String.Format(sSQLSUM, sFieldList, "RPT_ITM_Y", sGroupBy)
                    sSQL = sSQLDateCTE & sWHEREDateCTE & sSQLSUM & sSQLFinalPart
            End Select

            sqlCmd.CommandText = sSQL

            sqlCmd.Parameters.AddWithValue("@UPCCode", sUPCCode)

            oDT = oAppEnv.oLogiDM.GetSQLData(sqlCmd)

            ctSalesData.ChartAreas.Clear()
            ctSalesData.ChartAreas.Add("Sales")
            ctSalesData.Series.Clear()

            If oDT IsNot Nothing Then

                '//Get the Date range.

                Dim oSortDV As DataView = oDT.DefaultView
                oSortDV.Sort = "UnitsSold DESC"

                'ctSalesData.DataSource = oDT
                Dim iCnt As Integer = 0

                ctSalesData.AlignDataPointsByAxisLabel()

                If oAppEnv.sSource = "H" And sStorelist <> "" Then
                    For Each CheckedItem In clbStores.CheckedItems
                        Dim oStoreRows() As DataRow = oDT.Select("Store = " & CheckedItem.key)
                        iCnt = 0
                        Dim cSeries As New Charting.Series(CheckedItem.key)
                        cSeries.ChartType = Charting.SeriesChartType.Bar
                        cSeries.IsXValueIndexed = True
                        cSeries.CustomProperties = "PixelPointWidth = 20"
                        cSeries.IsValueShownAsLabel = True
                        For Each row In oStoreRows
                            cSeries.Points.AddXY(iCnt, row.Item("UnitsSold"))
                            cSeries.Points(iCnt).AxisLabel = row.Item("SaleDate")
                            iCnt += 1
                        Next
                        ctSalesData.Series.Add(cSeries)
                    Next
                Else
                    Dim cSeries As New Charting.Series("Sales")
                    cSeries.ChartType = Charting.SeriesChartType.Bar
                    cSeries.IsXValueIndexed = True
                    cSeries.CustomProperties = "PixelPointWidth = 15"
                    cSeries.IsValueShownAsLabel = True

                    For Each row In oDT.Rows
                        cSeries.Points.AddXY(iCnt, row.item("UnitsSold"))
                        cSeries.Points(iCnt).AxisLabel = row.item("SaleDate")
                        iCnt += 1
                    Next
                    ctSalesData.Series.Add(cSeries)
                End If

                ctSalesData.ChartAreas(0).AxisX.Minimum = 0
                ctSalesData.ChartAreas(0).AxisX.Maximum = oDT.Rows.Count + 1

                If oDT.Rows.Count > 21 Then
                    Dim ZoomDate As Date = oDT.Rows(14).Item("SaleDate")
                    ctSalesData.ChartAreas(0).AxisX.ScaleView.Zoom(0, 22)
                End If

                ctSalesData.ChartAreas(0).AxisX.Interval = 1
                ctSalesData.ChartAreas(0).AxisY.Minimum = 0
                ctSalesData.ChartAreas(0).AxisY.Interval = 1

                ctSalesData.ChartAreas(0).AxisY.Maximum = Math.Ceiling(oSortDV(0).Item("UnitsSold") / 10) * 10

                If ctSalesData.ChartAreas(0).AxisY.Maximum = oSortDV(0).Item("UnitsSold") Then
                    ctSalesData.ChartAreas(0).AxisY.Maximum += 10
                End If

                ctSalesData.ChartAreas(0).CursorX.AutoScroll = True

                ctSalesData.ChartAreas(0).AxisX.ScaleView.SizeType = Charting.DateTimeIntervalType.Number
                ctSalesData.ChartAreas(0).AxisX.ScrollBar.ButtonStyle = Charting.ScrollBarButtonStyles.SmallScroll

                ctSalesData.ChartAreas(0).AxisX.ScaleView.SmallScrollSize = 21
                ctSalesData.ChartAreas(0).AxisX.ScrollBar.IsPositionedInside = False


            End If


        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
End Sub

QuestionHow to determine specific object from Msg.HWnd 'MESSAGE CLOSED' Pin
speedbump9925-Nov-19 2:32
Memberspeedbump9925-Nov-19 2:32 
QuestionMessage Closed Pin
17-Nov-19 20:37
professionalMorgan Lang17-Nov-19 20:37 
AnswerRe: can not find the pin Pin
Richard MacCutchan17-Nov-19 21:17
mveRichard MacCutchan17-Nov-19 21:17 
Questiongroup by name for sum amount Pin
Member 1332257413-Nov-19 19:39
MemberMember 1332257413-Nov-19 19:39 
AnswerRe: group by name for sum amount Pin
Dave Kreskowiak14-Nov-19 2:40
mveDave Kreskowiak14-Nov-19 2:40 
Questioncode project data base Pin
abuahmed20191-Nov-19 4:24
Memberabuahmed20191-Nov-19 4:24 
AnswerRe: code project data base Pin
Dave Kreskowiak1-Nov-19 5:00
mveDave Kreskowiak1-Nov-19 5:00 
QuestionSystem.IO.IOException HResult=0x80131620 When using NetworkStream.Read function Pin
fd975029-Oct-19 22:48
professionalfd975029-Oct-19 22:48 
AnswerRe: System.IO.IOException HResult=0x80131620 When using NetworkStream.Read function Pin
Richard MacCutchan29-Oct-19 23:09
mveRichard MacCutchan29-Oct-19 23:09 
GeneralRe: System.IO.IOException HResult=0x80131620 When using NetworkStream.Read function Pin
fd975029-Oct-19 23:23
professionalfd975029-Oct-19 23:23 
GeneralRe: System.IO.IOException HResult=0x80131620 When using NetworkStream.Read function Pin
fd975030-Oct-19 0:02
professionalfd975030-Oct-19 0:02 
QuestionHow to solve problem with datagrid and tabcontrol(vb.net) Pin
Member 1447080727-Oct-19 22:52
MemberMember 1447080727-Oct-19 22:52 
AnswerRe: How to solve problem with datagrid and tabcontrol(vb.net) Pin
Richard MacCutchan27-Oct-19 23:14
mveRichard MacCutchan27-Oct-19 23:14 
GeneralRe: How to solve problem with datagrid and tabcontrol(vb.net) Pin
Member 1447080730-Oct-19 17:33
MemberMember 1447080730-Oct-19 17:33 
GeneralRe: How to solve problem with datagrid and tabcontrol(vb.net) Pin
Richard MacCutchan30-Oct-19 22:58
mveRichard MacCutchan30-Oct-19 22:58 
QuestionVB Script stopped working on Windows 10 + Office 365 Pro Pin
Member 1463660627-Oct-19 21:29
MemberMember 1463660627-Oct-19 21:29 
AnswerRe: VB Script stopped working on Windows 10 + Office 365 Pro Pin
OriginalGriff27-Oct-19 21:33
mveOriginalGriff27-Oct-19 21:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.