VB.Net chart point label not displaying - vb.net

I'm trying to add a label to a point in VB.Net using the Chart control. Here's my code:
chartMain.Series(1).Points.AddXY(x, y)
chartMain.Series(1).Points(chartMain.Series(1).Points.Count - 1).Label = Math.Round(x, 2) & "nm, " & Math.Round(y, 2) & "%"
However no labels are being displayed. In another program I do this exact same thing and it works perfectly. Is there something I'm missing or may have inadvertently disabled elsewhere?

Try:
ChartMain.Series(1).Points.AddXY(Math.Round(x, 2) & "nm, " & Math.Round(y, 2) & "%", y)

Fixed -
Data point type of "Fast Point" will not display labels, it seems. Changing to just "Point" worked.

Related

Setting Form Field to autopopulate with previous record entry for text, date, and combo box

I am still very new to most vba coding. I'm trying to do pretty much the exact same thing as with this post:
Microsoft Access Form Setting Default Value to Previous Entry for Both Text Boxes and Drop Down Lists
but nothing from it seems to be working for me. I want to populate each field in the form with the previous record's data via a button Autofill_Click()
Private Sub Autofill_Click()
Me!DateTimeID.DefaultValue = Me![DateTimeID].Value
Me.frmDate.DefaultValue = "#" & Me.frmDate & "#"
Me.Location.DefaultValue = "'" & Me.Location & "'"
End Sub
I'm receiving the error code "type mismatch" for the first line with DateTimeID, as well as an error code "There is an invalid use of the . or ! operator or invalid parentheses." for the second line with frmDate. The third line isn't even throwing an error code, but it isn't populating the desired field (or any field, for that matter) with what I want.
Any help would be much appreciated.
For text:
Me.[DateTimeID].DefaultValue = "'" & Me.[DateTimeID] & "'"
For date/time:
Me.frmDate.DefaultValue = "#" & Me.frmDate & "#"
For number:
Me.Quantity.DefaultValue = Me.Quantity
Code is usually put in control's AfterUpdate event so user doesn't have to do anything other than normal data entry/edit.

Tell a chart that the first two rows should be the legend area?

When I change a charts source data with the following command:
wksGraph.ChartObjects("Split").Chart.SetSourceData Source:=wksGraph.Range("$AA$2:$AE$" & FirstEmptyRow(wksGraphSplit.Range("$AA$3")) - 1)
The first row becomes the legend as you can see in this image. But can I instead tell Excel to treat the first two rows as legend?
Would this not suffice? The solution would be to simply specify the correct labels by concatenating the values as desired.
Range("AB2").Value = Range("AB1").Value & " " & Range("AB2").Value
Range("AC2").Value = Range("AC1").Value & " " & Range("AB2").Value
Range("AD2").Value = Range("AD1").Value & " " & Range("AD2").Value
Range("AE2").Value = Range("AE1").Value & " " & Range("AD2").Value
wksGraph.ChartObjects("Split").Chart.SetSourceData Source:=wksGraph.Range("$AA$2:$AE$" & FirstEmptyRow(wksGraphSplit.Range("$AA$3")) - 1
I checked to see if you could hijack the legend entries, but it appears not.
From the MS documentation on the LegendEntry, the text cannot be changed and is linked to the source:
The text of a legend entry cannot be changed. LegendEntry objects support font formatting, and they can be deleted. No pattern
formatting is supported for legend entries. The position and size of
entries is fixed.

How can I remove the initial return when the multiple texts are added to the field?

I am asking the user to select a txt file from a specified folder on a server [This is in PowerPoint 2007], but I need to give them the option of selecting more than one, so I have a bit of conditional code to determine this.
One file selected uses this code:
oShape.TextFrame.TextRange.Text = Text
More than one file selected currently uses this:
oShape.TextFrame.TextRange.Text = oShape.TextFrame.TextRange.Text & vbCrLf & vbCrLf & Text
…but this results in an extra return space above it all in the field, which is a bit untidy.
Could anyone advise me on how I can modify this to only get the returns in between the two texts, but not at the beginning?
I am not entirely sure I got the problem, but I believe this will do:
oShape.TextFrame.TextRange.Text = iif(oShape.TextFrame.TextRange.Text <> "", oShape.TextFrame.TextRange.Text & vbCrLf & vbCrLf, "") & Text

Use the actual value of String as a Formatted Value for TextBlock.Text

So basically I have this:
A WPF window with 1 Button (btn_Convert) and 2 TextBoxes (txtBox_StringValue and txtBox_Result).
In txtBox_StringValue I then paste in a formatted string value:
"This is a Header" & vbCrLf & "======================" & _
vbCrLf & "INFO" & vbCrLf & "======================"
Then when I click btn_Convert I would like the following to happen.
Code:
Dim tempStringValue = txtBox_StringValue.Text
txtBox_Results.Text = tempStringValue
However (obviously), when I do the above the Results TextBox just displays the string again:
"This is a Header" & vbCrLf & "======================" & _
vbCrLf & "INFO" & vbCrLf & "======================"
Instead of:
This is a Header
======================
INFO
So how do I get the value of the string and then strip the containing double-quotes so that the value when assigned acts like it was a variable value set in code, not just passing a string.
From the research I have done I am guessing that I need to use Reflection, however I am not familiar with the Reflection concept and don't know how to approach it.
Any help would be greatly appreciated!
Reflection won't help you in this case. It sounds like what you're talking about is dynamically interpreting some VB.NET source code and output the result of executing that code to another text box. In that case you need to use the Code DOM classes to dynamically build an assembly in memory and execute it.

VB big block of text?

Is there a way of putting a block of text (ie a paragraph) without using the label tool?
Thanks
Dim myString As String = "Hello world " + ControlChars.NewLine + _
" trying the next line of code " + ControlChars.NewLine + _
" trying the third line of code..."
Label1.Text = myString
Fixed, this works for me.
Regardless of winform or webform, you can store your very large text in a file and use System.IO.File.File.ReadAllText Method to read that block of text and assign the read text to relevant control.