我想从文本框中创建一个整数数组。
文本框中的格式字符串为80,139,22,135等。
到目前为止,这就是我所拥有的。如果文本框为80或139或22或任何没有“,”或空格
,则此方法有效
redisOperations
但是当我将texbox中的值更改为80,139,135时,我收到此错误..
从字符串“80,139,135”到“整数”类型的转换无效。
然后我试图将字符串转换为整数..就像这样..
Dim XPort = {TxtScanPort.Text}.ToList
For Each BPort As Integer In XPort 'ERROR
Blahh.. blahh.. blahh..
然后我又出现了一个错误..
输入字符串的格式不正确。
我尝试了很多代码,但是大多数代码都会导致相同的错误“输入字符串的格式不正确”
答案 0 :(得分:1)
不是String.Split()的粉丝(获得真正的CSV解析器),但这是quick'n'dirty选项:
For Each BPort As Integer In TxtScanPort.Text.Split(",".ToCharArray()).Select(Function(i) CInt(i.Trim()))
答案 1 :(得分:1)
如果每个值都以逗号分隔,则此方法应该有效。
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Values() As Integer = Array.ConvertAll(TxtScanPort.Text.Split(","c),
New Converter(Of String, Integer)(Function(input)
Dim output As Integer = 0
Integer.TryParse(input, output)
Return output
End Function))
For Each BPort As Integer In Values
Console.WriteLine(BPort)
Next
End Sub
End Class
答案 2 :(得分:0)
以下代码是ArrayDemo.xaml的代码:
'Declarations:Nested_Buttons
Dim WM As Window=New Window:Dim canvas1 As Canvas=New Canvas
Dim vb As Viewbox = New Viewbox()
Dim btn1 As Button=New Button:Dim btn2 As Button=New Button
Dim Editor As TextBox=New TextBox
Dim ay0 As TextBox = New TextBox:Dim ay1 As TextBox = New TextBox
Dim ay2 As TextBox = New TextBox:Dim ay3 As TextBox = New TextBox
Dim ay4 As TextBox = New TextBox:Dim ay5 As TextBox = New TextBox
Dim ay6 As TextBox = New TextBox:Dim ay7 As TextBox = New TextBox
Dim ay8 As TextBox = New TextBox:Dim ay9 As TextBox = New TextBox
Dim ay10 As TextBox = New TextBox:Dim ay11 As TextBox = New TextBox
Dim ay12 As TextBox = New TextBox:Dim ay13 As TextBox = New TextBox
Dim ay14 As TextBox = New TextBox:Dim ay15 As TextBox = New TextBox
Dim ay16 As TextBox = New TextBox:Dim ay17 As TextBox = New TextBox
Dim ay18 As TextBox = New TextBox:Dim ay19 As TextBox = New TextBox
Dim ay20 As TextBox = New TextBox:Dim ay21 As TextBox = New TextBox
Dim ay22 As TextBox = New TextBox:Dim ay23 As TextBox = New TextBox
Dim ay24 As TextBox = New TextBox:Dim ay25 As TextBox = New TextBox
Dim ay26 As TextBox = New TextBox:Dim ay27 As TextBox = New TextBox
Dim ay28 As TextBox = New TextBox:Dim ay29 As TextBox = New TextBox
Dim ay30 As TextBox = New TextBox:Dim ay31 As TextBox = New TextBox
Dim i As Integer=Nothing:Dim j As Integer=Nothing:Dim k As Integer=Nothing
Dim gradientBrush3 As New LinearGradientBrush(Color.FromRgb(175,238,238),Color.FromRgb(255,255,0), _
New Point(0.5, 0),New Point(0.5, 1))
Sub New()
WM.Width=1900:WM.Height=1040:WM.Background=Brushes.MediumSlateBlue:WM.Content=vb:WM.Left=0:WM.Top=0
WM.Title="ArrayDemo":vb.Child=canvas1:canvas1.Width=1875:canvas1.Height=960
vb.Width=1600:vb.Height=950
btn1.Width=150:btn1.Height=60:btn1.Margin=New Thickness(0,0,0,0)
btn1.Background=New SolidColorBrush(Colors.Brown)
btn1.FontSize=20:btn1.Foreground=New SolidColorBrush(Colors.White)
btn1.HorizontalAlignment=System.Windows.HorizontalAlignment.Left
btn1.Content = New TextBlock With {.Text = "ArrayDemo", _
.TextWrapping = TextWrapping.Wrap}
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''Array TextBoxes
ay0.Width=30:ay0.Height=43:ay0.Foreground=New SolidColorBrush(Colors.Black)
ay0.Background=gradientBrush3:ay0.FontSize=23
ay0.FontWeight=FontWeights.UltraBold:ay0.Text="0"
ay0.Margin=New Thickness(152,0,0,0)
ay1.Width=30:ay1.Height=43:ay1.Foreground=New SolidColorBrush(Colors.Black)
ay1.Background=gradientBrush3:ay1.FontSize=23
ay1.FontWeight=FontWeights.UltraBold:ay1.Text="1"
ay1.Margin=New Thickness(184,0,0,0)
ay2.Width=30:ay2.Height=43:ay2.Foreground=New SolidColorBrush(Colors.Black)
ay2.Background=gradientBrush3:ay2.FontSize=23
ay2.FontWeight=FontWeights.UltraBold:ay2.Text="1"
ay2.Margin=New Thickness(216,0,0,0)
ay3.Width=30:ay3.Height=43:ay3.Foreground=New SolidColorBrush(Colors.Black)
ay3.Background=gradientBrush3:ay3.FontSize=23
ay3.FontWeight=FontWeights.UltraBold:ay3.Text="3"
ay3.Margin=New Thickness(248,0,0,0)
ay4.Width=30:ay4.Height=43:ay4.Foreground=New SolidColorBrush(Colors.Black)
ay4.Background=gradientBrush3:ay4.FontSize=23
ay4.FontWeight=FontWeights.UltraBold:ay4.Text="1"
ay4.Margin=New Thickness(280,0,0,0)
ay5.Width=30:ay5.Height=43:ay5.Foreground=New SolidColorBrush(Colors.Black)
ay5.Background=gradientBrush3:ay5.FontSize=23
ay5.FontWeight=FontWeights.UltraBold:ay5.Text="1"
ay5.Margin=New Thickness(312,0,0,0)
ay6.Width=30:ay6.Height=43:ay6.Foreground=New SolidColorBrush(Colors.Black)
ay6.Background=gradientBrush3:ay6.FontSize=23
ay6.FontWeight=FontWeights.UltraBold:ay6.Text="21"
ay6.Margin=New Thickness(344,0,0,0)
ay7.Width=30:ay7.Height=43:ay7.Foreground=New SolidColorBrush(Colors.Black)
ay7.Background=gradientBrush3:ay7.FontSize=23
ay7.FontWeight=FontWeights.UltraBold:ay7.Text="9"
ay7.Margin=New Thickness(376,0,0,0)
ay8.Width=30:ay8.Height=43:ay8.Foreground=New SolidColorBrush(Colors.Black)
ay8.Background=gradientBrush3:ay8.FontSize=23
ay8.FontWeight=FontWeights.UltraBold:ay8.Text="9"
ay8.Margin=New Thickness(408,0,0,0)
ay9.Width=30:ay9.Height=43:ay9.Foreground=New SolidColorBrush(Colors.Black)
ay9.Background=gradientBrush3:ay9.FontSize=23
ay9.FontWeight=FontWeights.UltraBold:ay9.Text="1"
ay9.Margin=New Thickness(440,0,0,0)
ay10.Width=30:ay10.Height=43:ay10.Foreground=New SolidColorBrush(Colors.Black)
ay10.Background=gradientBrush3:ay10.FontSize=23
ay10.FontWeight=FontWeights.UltraBold:ay10.Text="3"
ay10.Margin=New Thickness(472,0,0,0)
ay11.Width=30:ay11.Height=43:ay11.Foreground=New SolidColorBrush(Colors.Black)
ay11.Background=gradientBrush3:ay11.FontSize=23
ay11.FontWeight=FontWeights.UltraBold:ay11.Text="3"
ay11.Margin=New Thickness(504,0,0,0)
ay12.Width=30:ay12.Height=43:ay12.Foreground=New SolidColorBrush(Colors.Black)
ay12.Background=gradientBrush3:ay12.FontSize=23
ay12.FontWeight=FontWeights.UltraBold:ay12.Text="3"
ay12.Margin=New Thickness(536,0,0,0)
ay13.Width=30:ay13.Height=43:ay13.Foreground=New SolidColorBrush(Colors.Black)
ay13.Background=gradientBrush3:ay13.FontSize=23
ay13.FontWeight=FontWeights.UltraBold:ay13.Text="1"
ay13.Margin=New Thickness(568,0,0,0)
ay14.Width=30:ay14.Height=43:ay14.Foreground=New SolidColorBrush(Colors.Black)
ay14.Background=gradientBrush3:ay14.FontSize=23
ay14.FontWeight=FontWeights.UltraBold:ay14.Text="5"
ay14.Margin=New Thickness(600,0,0,0)
ay15.Width=30:ay15.Height=43:ay15.Foreground=New SolidColorBrush(Colors.Black)
ay15.Background=gradientBrush3:ay15.FontSize=23
ay15.FontWeight=FontWeights.UltraBold:ay15.Text="5"
ay15.Margin=New Thickness(632,0,0,0)
ay16.Width=30:ay16.Height=43:ay16.Foreground=New SolidColorBrush(Colors.Black)
ay16.Background=gradientBrush3:ay16.FontSize=23
ay16.FontWeight=FontWeights.UltraBold:ay16.Text="31"
ay16.Margin=New Thickness(664,0,0,0)
ay17.Width=30:ay17.Height=43:ay17.Foreground=New SolidColorBrush(Colors.Black)
ay17.Background=gradientBrush3:ay17.FontSize=23
ay17.FontWeight=FontWeights.UltraBold:ay17.Text="11"
ay17.Margin=New Thickness(696,0,0,0)
ay18.Width=30:ay18.Height=43:ay18.Foreground=New SolidColorBrush(Colors.Black)
ay18.Background=gradientBrush3:ay18.FontSize=23
ay18.FontWeight=FontWeights.UltraBold:ay18.Text="9"
ay18.Margin=New Thickness(728,0,0,0)
ay19.Width=30:ay19.Height=43:ay19.Foreground=New SolidColorBrush(Colors.Black)
ay19.Background=gradientBrush3:ay19.FontSize=23
ay19.FontWeight=FontWeights.UltraBold:ay19.Text="1"
ay19.Margin=New Thickness(760,0,0,0)
ay20.Width=30:ay20.Height=43:ay20.Foreground=New SolidColorBrush(Colors.Black)
ay20.Background=gradientBrush3:ay20.FontSize=23
ay20.FontWeight=FontWeights.UltraBold:ay20.Text="3"
ay20.Margin=New Thickness(792,0,0,0)
ay21.Width=30:ay21.Height=43:ay21.Foreground=New SolidColorBrush(Colors.Black)
ay21.Background=gradientBrush3:ay21.FontSize=23
ay21.FontWeight=FontWeights.UltraBold:ay21.Text="1"
ay21.Margin=New Thickness(824,0,0,0)
ay22.Width=30:ay22.Height=43:ay22.Foreground=New SolidColorBrush(Colors.Black)
ay22.Background=gradientBrush3:ay22.FontSize=23
ay22.FontWeight=FontWeights.UltraBold:ay22.Text="3"
ay22.Margin=New Thickness(856,0,0,0)
ay23.Width=30:ay23.Height=43:ay23.Foreground=New SolidColorBrush(Colors.Black)
ay23.Background=gradientBrush3:ay23.FontSize=23
ay23.FontWeight=FontWeights.UltraBold:ay23.Text="7"
ay23.Margin=New Thickness(888,0,0,0)
ay24.Width=30:ay24.Height=43:ay24.Foreground=New SolidColorBrush(Colors.Black)
ay24.Background=gradientBrush3:ay24.FontSize=23
ay24.FontWeight=FontWeights.UltraBold:ay24.Text="51"
ay24.Margin=New Thickness(920,0,0,0)
ay25.Width=30:ay25.Height=43:ay25.Foreground=New SolidColorBrush(Colors.Black)
ay25.Background=gradientBrush3:ay25.FontSize=23
ay25.FontWeight=FontWeights.UltraBold:ay25.Text="5"
ay25.Margin=New Thickness(952,0,0,0)
ay26.Width=30:ay26.Height=43:ay26.Foreground=New SolidColorBrush(Colors.Black)
ay26.Background=gradientBrush3:ay26.FontSize=23
ay26.FontWeight=FontWeights.UltraBold:ay26.Text="1"
ay26.Margin=New Thickness(984,0,0,0)
ay27.Width=30:ay27.Height=43:ay27.Foreground=New SolidColorBrush(Colors.Black)
ay27.Background=gradientBrush3:ay27.FontSize=23
ay27.FontWeight=FontWeights.UltraBold:ay27.Text="1"
ay27.Margin=New Thickness(1016,0,0,0)
ay28.Width=30:ay28.Height=43:ay28.Foreground=New SolidColorBrush(Colors.Black)
ay28.Background=gradientBrush3:ay28.FontSize=23
ay28.FontWeight=FontWeights.UltraBold:ay28.Text="1"
ay28.Margin=New Thickness(1048,0,0,0)
ay29.Width=30:ay29.Height=43:ay29.Foreground=New SolidColorBrush(Colors.Black)
ay29.Background=gradientBrush3:ay29.FontSize=23
ay29.FontWeight=FontWeights.UltraBold:ay29.Text="1"
ay29.Margin=New Thickness(1080,0,0,0)
ay30.Width=30:ay30.Height=43:ay30.Foreground=New SolidColorBrush(Colors.Black)
ay30.Background=gradientBrush3:ay30.FontSize=23
ay30.FontWeight=FontWeights.UltraBold:ay30.Text="1"
ay30.Margin=New Thickness(1112,0,0,0)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''Array TextBoxes
Editor.TextWrapping=TextWrapping.Wrap:Editor.AcceptsReturn = True
Editor.Width=1840:Editor.Height=900:Editor.Margin=New Thickness(0,62,0,0)
Editor.Background=New SolidColorBrush(Colors.White)
Editor.Foreground=New SolidColorBrush(Colors.Navy)
Editor.FontSize=22:Editor.FontWeight=FontWeights.UltraBold
Editor.HorizontalScrollBarVisibility=ScrollBarVisibility.Visible
Editor.VerticalScrollBarVisibility=ScrollBarVisibility.Visible
Editor.HorizontalContentAlignment=HorizontalAlignment.Left
canvas1.Children.Add(btn1):canvas1.Children.Add(Editor)
canvas1.Children.Add(ay0):canvas1.Children.Add(ay1):canvas1.Children.Add(ay2)
canvas1.Children.Add(ay3):canvas1.Children.Add(ay4):canvas1.Children.Add(ay5)
canvas1.Children.Add(ay6):canvas1.Children.Add(ay7):canvas1.Children.Add(ay8)
canvas1.Children.Add(ay9):canvas1.Children.Add(ay10):canvas1.Children.Add(ay11)
canvas1.Children.Add(ay12):canvas1.Children.Add(ay13):canvas1.Children.Add(ay14)
canvas1.Children.Add(ay15):canvas1.Children.Add(ay16):canvas1.Children.Add(ay17)
canvas1.Children.Add(ay18):canvas1.Children.Add(ay19):canvas1.Children.Add(ay20)
canvas1.Children.Add(ay21):canvas1.Children.Add(ay22):canvas1.Children.Add(ay23)
canvas1.Children.Add(ay24):canvas1.Children.Add(ay25):canvas1.Children.Add(ay26)
canvas1.Children.Add(ay27):canvas1.Children.Add(ay28):canvas1.Children.Add(ay29)
canvas1.Children.Add(ay30)
AddHandler btn1.Click,AddressOf btn1Handler
WM.Show()
End Sub
Public Sub btn1Handler(sender As Object,e As EventArgs)
Try
Dim arr1() As Integer = {Integer.Parse(ay0.Text),Integer.Parse(ay1.Text),Integer.Parse(ay2.Text),Integer.Parse(ay3.Text), _
Integer.Parse(ay4.Text),Integer.Parse(ay5.Text),Integer.Parse(ay6.Text),Integer.Parse(ay7.Text), _
Integer.Parse(ay8.Text),Integer.Parse(ay9.Text),Integer.Parse(ay10.Text),Integer.Parse(ay11.Text), _
Integer.Parse(ay12.Text),Integer.Parse(ay13.Text),Integer.Parse(ay14.Text),Integer.Parse(ay15.Text), _
Integer.Parse(ay16.Text),Integer.Parse(ay17.Text),Integer.Parse(ay18.Text),Integer.Parse(ay19.Text), _
Integer.Parse(ay20.Text),Integer.Parse(ay21.Text),Integer.Parse(ay22.Text),Integer.Parse(ay23.Text), _
Integer.Parse(ay24.Text),Integer.Parse(ay25.Text),Integer.Parse(ay26.Text),Integer.Parse(ay27.Text), _
Integer.Parse(ay28.Text),Integer.Parse(ay29.Text),Integer.Parse(ay30.Text)}
Dim sName As Hashtable = New Hashtable
sName.Add(1,"pwBox"):sName.Add(2,"vwBox"):sName.Add(3,"canvas"):sName.Add(4,"tlbrTray"):
sName.Add(5,"menuStrip"):sName.Add(6,"menu"):sName.Add(7,"sbMenu"):sName.Add(8,"mnMenu")
sName.Add(9,"tlTip"):sName.Add(10,"grpBox"):sName.Add(11,"wrpPanel"):sName.Add(12,"dckPanel")
sName.Add(13,"ufrmGrid"):sName.Add(14,"expr"):sName.Add(15,"border"):sName.Add(16,"btn")
sName.Add(17,"label"):sName.Add(18,"tbx"):sName.Add(19,"Editor"):sName.Add(20,"listBox")
sName.Add(21,"rtxBox"):sName.Add(22,"cboBox"):sName.Add(23,"chkBox"):sName.Add(24,"rdoBtn")
sName.Add(25,"tglBtn"):sName.Add(26,"prgsBar"):sName.Add(27,"slider"):sName.Add(28,"scrlBar")
sName.Add(29,"cusContrl1"):sName.Add(30,"cusContrl2")
Dim ctrlName As Hashtable = New Hashtable
ctrlName.Add(1,"PasswordBox"):ctrlName.Add(2,"ViewBox"):ctrlName.Add(3,"Canvas"):ctrlName.Add(4,"ToolBarTray")
ctrlName.Add(5,"Menu"):ctrlName.Add(6,"MenuItem"):ctrlName.Add(7,"MenuItem"):ctrlName.Add(8,"MenuItem")
ctrlName.Add(9,"ToolTip"):ctrlName.Add(10,"GroupBox"):ctrlName.Add(11,"wrapPanel"):ctrlName.Add(12,"DockPanel")
ctrlName.Add(13,"UniformGrid"):ctrlName.Add(14,"Expander"):ctrlName.Add(15,"Border"):ctrlName.Add(16,"Button")
ctrlName.Add(17,"Label"):ctrlName.Add(18,"TextBox"):ctrlName.Add(19,"TextBox"):ctrlName.Add(20,"ListBox")
ctrlName.Add(21,"RichTextBox"):ctrlName.Add(22,"ComboBox"):ctrlName.Add(23,"CheckBox"):ctrlName.Add(24,"RadioButton")
ctrlName.Add(25,"ToggleButton"):ctrlName.Add(26,"ProgressBar"):ctrlName.Add(27,"Slider"):ctrlName.Add(28,"ScrollBar")
ctrlName.Add(29,"CustomControl"):ctrlName.Add(30,"CustomControl")
Try
For j=1 To 30 Step 1
Editor.Text &="Dim" & Space(1) & sName(j) & 1 & Space(1) & "As" & Space(1) & _
ctrlName(j) & "=New" & Space(1) & ctrlName(j) & VbCrLf
For i=1 To arr1(j)-1 Step 2
Editor.Text &="Dim" & Space(1) & sName(j) & i+1 & Space(1) & "As" & Space(1) & _
ctrlName(j) & "=New" & Space(1) & ctrlName(j) & ":" & _
"Dim" & Space(1) & sName(j) & i+2 & Space(1) & "As" & Space(1) & _
ctrlName(j) & "=New" & Space(1) & ctrlName(j) & VbCrLf
Next
Next
Catch ex As Exception
End Try
Catch ex As Exception
End Try
End Sub
以下文件是ArrayDemo.vbproj的文件:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BE9B3350-5541-4EB5-BD4D-F6938B472E5E}</ProjectGuid>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>
<OutputType>WinExe</OutputType>
<RootNamespace>ArrayDemo</RootNamespace>
<AssemblyName>ArrayDemo</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<MyType>Custom</MyType>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<IncrementalBuild>true</IncrementalBuild>
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>ArrayDemo.xml</DocumentationFile>
<NoWarn>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System.Core" />
<Reference Include="System.Windows" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="ArrayDemo.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Imports Include="System.Windows.Documents" />
<Import Include="System.Collections.Generic" />
<Import Include="System.Collections" />
<Import Include="System.ComponentModel" />
<Import Include="Microsoft.VisualBasic" />
<Import Include="Microsoft.Win32" />
<Import Include="System.Windows.Application" />
<Import Include="System.IO" />
<Import Include="System" />
<Import Include="System.Web" />
<Import Include="System.Windows" />
<Import Include="System.Windows.Controls" />
<Import Include="System.Windows.Threading" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
</Project>
cmd的编译代码如下所示-将带有ArrayDemo.xaml和ArrayDemo.vbproj的项目文件夹放在D:\驱动器中,然后从cmd调用编译代码。您的GUI将在屏幕上弹出-我已经减小了视图框的大小以适合较小的屏幕尺寸。如果您的屏幕尺寸不同,请重新调整视图框尺寸。