Line control in vb.net - vb.net

I am new to .net world, got some work to convert the VB 6 code to VB.net
where OptionLine is a LINE Control & intCurrentControlTop is a integer variable
'Create line
Load Line(count)
Line(count).Y1 = 20
Line(count).Y2 = 30
Line(count).X1 = Line(0).X1
Line(count).X2 = Line(0).X2
Line(count).Visible = True
when I am trying to convert the above code using VS2005 wizard, it treated Line variable as Label and give me below version
Line As Microsoft.VisualBasic.Compatibility.VB6.LabelArray
Line.Load(count)
Line(count).Y1 = 20
Line(count).Y2 = 30
Line(count).X1 = Line(0).X1
Line(count).X2 = Line(0).X2
Line(count).Visible = True
Now when I am compiling , Error = X1 is not a member of System.Windows.Forms.Label
can some one help

Related

Create Array of Labels

I'm really hoping to find some way to either create an Array of Label() or to create a Label variable with a constructed name using a string. Unfortunately after searching I'm afraid it won't be possible so I'm looking for alternatives as well.
I have a List of Strings, and I would like to create a Label for each one, inside of a Form using System.Windows.Forms. I am hoping to avoid having one large label holding all of the text, or needing to create a large number of predefined labels, as the number of Strings my list contains will vary from 3 or 4 to 30 or higher.
After some trial and error I have managed to get it not crashing, and the information I am setting to the Label is setting correctly, but becomes nothing outside of the For Loop.
Sub CheckResult(ByRef strList As List(Of String))
Dim LineCount As Integer = strList.Count
Dim Line As String
With CheckForm
.size = New System.Drawing.Size(340, (LineCount * 20) + 40 )
.StartPosition = FormStartPosition.CenterScreen
.MaximizeBox = False
.MinimizeBox = False
.Text = CheckType
End With
Dim CheckTextLabel(0 To LineCount - 1) As Label
Dim i As Integer = 0
For Each Line In strList
Line = strList(i)
CheckTextLabel(i) = New Label()
With CheckTextLabel(i)
.Text = Line
.Size = New System.Drawing.Size(320, 20)
.Location = New System.Drawing.Point(10, 10 + (LineCount * 20))
'.Font = MidFont
End With
CheckForm.Controls.Add(CheckTextLabel(i))
'Location 1
i += 1
Next
'Location 2
...
When I check the value of CheckTextLabel(i).Text at Location 1, I get the expected value.
If I check the value of CheckTextLabel(1) or any other value for i at Location 2, it returns a blank result.
Please let me know if there is a way to do this, and if as I fear there is not, I'll accept alternatives

Why Does It Make A Difference If A Macro is Run When Slide Show Has Started

Apologies if this is a basic question, but I am a newbie at VBA and have spent the past two weeks learning the language. I am trying to make a learning resource using PowerPoint.
I made a good macro which seems to work perfectly when it is run outside the slide show. (I typically just pressed F5 within my VBA Editor to see what the code was doing.) However, when I try running the macro when the slide show is running (using an action button) it does not work as intended. To be more precise it appears to stop running and not show any errors or provide reasons why the macro has stopped.
I tried doing a Google search on this topic, but could not find anything. I would be very grateful if anyone could provide any reasons or suggest any information sources as to why macros work differently when the slide show is running as opposed to not running? Are there any standard practices to ensure that the macros will work when the slide show is run?
Thank you for any comments!
EDIT 02/07/20 - responding to a comment I attach the code below and have explained what I am trying to do in comments below
Sub DataInputMacro()
'This procedure attempts to group (and do a check) of all 20 answer tiles.
Dim oSh As Shape
Dim i As Integer 'This is for the For statement
Dim iix As Integer 'This is to store the x position of the tiles.
Dim iiy As Integer 'This is to store the y position of the tiles.
For i = 1 To 20
If i = 1 Or i = 3 Or i = 5 Or i = 7 Or i = 9 Then
iix = 9
ElseIf i = 2 Or i = 4 Or i = 6 Or i = 8 Or i = 10 Then
iix = 198
ElseIf i = 11 Or i = 13 Or i = 15 Or i = 17 Or i = 19 Then
iix = 587
Else
iix = 774
End If
If i = 1 Or i = 2 Or i = 11 Or i = 12 Then
iiy = 9
ElseIf i = 3 Or i = 4 Or i = 13 Or i = 14 Then
iiy = 113
ElseIf i = 5 Or i = 6 Or i = 15 Or i = 16 Then
iiy = 218
ElseIf i = 7 Or i = 8 Or i = 17 Or i = 18 Then
iiy = 323
Else
iiy = 428
End If
ActiveWindow.Selection.Unselect 'This ensures that nothing has already been selected on the slide (which could then get grouped with the first rectangle!)
For Each oSh In ActivePresentation.Slides("DataInput").Shapes
If IsWithinRange(oSh, iix - 1, iiy - 1, iix + 179, iiy + 97) Then
'MsgBox oSh.Name & " " & oSh.Left
oSh.Select (msoFalse)
End If
Next
If ActiveWindow.Selection.ShapeRange.Count > 1 Then
With ActiveWindow.Selection.ShapeRange.Group
.Name = "GroupAnswer" & i
.Select
End With
ElseIf ActiveWindow.Selection.ShapeRange.Type = msoGroup Then
ActiveWindow.Selection.ShapeRange.Name = "GroupAnswer" & i & "a"
ElseIf ActiveWindow.Selection.ShapeRange.Count = 1 Then
MsgBox "Sorry, but there is a set up issues of your answer boxes. Either (1) one of your answer boxes does not contain a separate textbox or image or (2) there is a missing yellow rectangle! I note for point (1) the text must be placed in a separate text box to the yellow rectangle!"
End
End If
Next i
UpdateTitle 'This is a separate function that updates the title on the front slide.
CheckFor20Groups 'This is a function that checks that there are 20 groups for the rest of the program to use!
End Sub
Shape.Select method does not work in slide view - see remarks here: Shape.Select method (PowerPoint) - so you will have to use another method for working with your shapes - try using a variable to refer to the ShapeRange you are working with rather than ActiveWindow.Selection.ShapeRange - that way you can work with them without needing to select them.

vb.net crystal report view issues

I have a vb.net application that has a list of reports that you can select from.
When you select a report it loads the data and displays the report in the Crystal Report Viewer. However, The report display is way to big and the only way to resize it is to restore down the screen and then restore it to full screen. The scroll bars are only visible after you restore the page down and up.
The generated code for the viewer is as follows.
Me.CrystalReportViewer1.ActiveViewIndex = -1
Me.CrystalReportViewer1.AutoValidate = System.Windows.Forms.AutoValidate.EnablePreventFocusChange
Me.CrystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.CrystalReportViewer1.Cursor = System.Windows.Forms.Cursors.Arrow
Me.CrystalReportViewer1.DisplayBackgroundEdge = False
Me.CrystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill
Me.CrystalReportViewer1.EnableDrillDown = False
Me.CrystalReportViewer1.Location = New System.Drawing.Point(230, 0)
Me.CrystalReportViewer1.Name = "CrystalReportViewer1"
Me.CrystalReportViewer1.SelectionFormula = ""
Me.CrystalReportViewer1.ShowCloseButton = False
Me.CrystalReportViewer1.ShowGroupTreeButton = False
Me.CrystalReportViewer1.ShowRefreshButton = False
Me.CrystalReportViewer1.ShowTextSearchButton = False
Me.CrystalReportViewer1.Size = New System.Drawing.Size(517, 715)
Me.CrystalReportViewer1.TabIndex = 1
Me.CrystalReportViewer1.ToolPanelView = CrystalDecisions.Windows.Forms.ToolPanelViewType.None
Me.CrystalReportViewer1.ViewTimeSelectionFormula = ""
I am calling it like this:
Dim rpt As String
rpt = ListBox1.Items(ListBox1.SelectedIndex)
If Not CrystalReportViewer1.ReportSource Is Nothing Then CrystalReportViewer1.ReportSource.dispose()
Select Case rpt
Case "Scoot"
myreport = New graduation
LoadDatabaseInfo(myreport)
myreport.SetParameterValue("doop", indrno.Text)
'myreport.SetParameterValue("dte", indate.Value)
myreport.SetParameterValue("name", txb.Text)
CrystalReportViewer1.ReportSource = myreport
CrystalReportViewer1.Refresh()
CrystalReportViewer1.Zoom(55)
How do I fix This.. Thank you so much
Rather than zooming to 55 percent, try using a value of 1 to fit to the width of the page or 2 to fit in the page (from MSDN).
I was able to accomplish my resizing needs by setting the height and width properties of the window to set pixel values.
i.e.
CrystalReportViewer.Width = 1100
CrystalReportViewer.Height = 1200
It takes some playing around to get your values correct but this worked and I didn't have any zooming issues.

Visual Basic - Getting value from an array with an integer

I currently Have an array ...
Dim mTeam(10) As String
In the Form load For visual basic i have
'Load Teams
mTeam(1) = "Oklahoma"
mTeam(2) = "USC"
mTeam(3) = "LSU"
mTeam(4) = "Michigan"
mTeam(5) = "Georgia"
mTeam(6) = "Texas"
mTeam(7) = "Tennessee"
mTeam(8) = "Ohio State"
mTeam(9) = "Florida State"
mTeam(10) = "Miami(FL)"
Now what im trying to do, is have the user enter a value between 1-10 in a textbox, and in return. A messagebox will appear with the team name.
Example:
User enters 5 into TextBoxNumber, a message box will apear when i hit button ButtonName, and in that message box it will have the word "Georgia".
TextBoxNumber (Name of input value)
ButtonName (button to do all the work and show messagebox)
Any help would be nice, i already have a try catch to have it only take integer values between 1 and 10.
PLEASE NOTE THIS IS FOR VISUAL BASIC , AND IM USING MICROSOFT VISUAL STUDIO 2010
You can attempt to convert the user's value to an integer, and if successful return the array value at that index:
Dim ind As Integer = -1
If Integer.TryParse(TextBoxNumber.Text, ind) Then
If ind >= 0 AndAlso ind < mTeam.Length
MessageBox.Show(mTeam(ind).ToString())
End If
End If

vb.Net code to use AX 2009 ReturnOrderInService web service

Need to use the create method of the AX 2009 ReturnOrderInService web service in a vb.NET aspx page to create an RMA in AX.
The code I've written below creates the RMA in AX, but doesn't show the line details in the AX RMA form, even though the records are in SalesTable and SalesLine.
Is a record needed in InventTrans or is there a missing InventRefId value somewhere?
Dim rmaClient As ReturnOrderInServiceClient = New ReturnOrderInServiceClient("WSHttpBinding_ReturnOrderInService1")
Dim roi As AxdReturnOrderIn = New AxdReturnOrderIn
Dim st As AxdEntity_SalesTable = New AxdEntity_SalesTable
st.CustAccount = "123"
st.ReturnReasonCodeId = "RRC1"
st.DlvMode = "01"
st.SalesType = 4 'return item
st.ReturnDeadline = DateAdd(DateInterval.Day, 15, Now())
Dim sl As AxdEntity_SalesLine = New AxdEntity_SalesLine
sl.ItemId = "ITEM 123"
sl.ExpectedRetQty = -2
sl.LineAmount = 0
sl.InventTransIdReturn = ""
st.SalesLine = New AxdEntity_SalesLine() {sl}
roi.SalesTable = New AxdEntity_SalesTable() {st}
txtFeedback.Text = ""
Try
Dim returnedSalesOrderEntityKey As EntityKey() = rmaClient.create(roi)
Dim returnedSalesOrder As EntityKey = CType(returnedSalesOrderEntityKey.GetValue(0), EntityKey)
txtFeedback.Text = GetRMANo(returnedSalesOrder.KeyData(0).Value)
Catch ex As Exception
txtFeedback.Text = ex.Message
End Try
rmaClient.Close()
Did you generate the proxy classes as stated in http://msdn.microsoft.com/en-us/library/cc652581(v=ax.50).aspx?
This should create the AxdEntity classes needed.
First I would try to translate the example to VB. I cannot help you with the specific syntax, but there is nothing fancy here, so it should be rather simple.
Regarding the use of web services in AX, see also:
http://www.axaptapedia.com/Webservice
http://blogs.msdn.com/b/aif/archive/2011/06/15/microsoft-dynamics-ax-2012-services-and-aif-white-papers.aspx
http://blogs.msdn.com/b/aif/archive/2007/11/28/consuming-the-customer-service-from-a-c-client.aspx (last part)
http://channel9.msdn.com/blogs/sanjayjain/microsoft-dynamics-ax-2009-aif-web-services-screencast