Преобразователь текста на MS Visual Basic.NET 9 (Framework 3.5 WPF)

Небольшая программа для преобразования текста в числовое значение определенного типа.


Дата: 19.05.2009 г.

Рейтинг: 2885

Метки:

Пошаговая инструкция:

Описание формы: Window1.xaml

<Window x:Class="Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/present..."
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Text converter" Height="492" Width="600">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="6" />
            <RowDefinition Height="362*" />
            <RowDefinition Height="0" />
            <RowDefinition Height="0" />
            <RowDefinition Height="6" />
            <RowDefinition Height="18" />
            <RowDefinition Height="6" />
            <RowDefinition Height="24" />
            <RowDefinition Height="6" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="6" />
            <ColumnDefinition Width="121*" />
            <ColumnDefinition Width="6" />
            <ColumnDefinition Width="142*" />
            <ColumnDefinition Width="10" />
            <ColumnDefinition Width="122*" />
            <ColumnDefinition Width="6" />
            <ColumnDefinition Width="143*" />
            <ColumnDefinition Width="6" />
        </Grid.ColumnDefinitions>
        <ProgressBar Grid.Row="7" Name="ProgressBar1" Grid.Column="3" Grid.ColumnSpan="5">
        </ProgressBar>
        <TextBox Grid.Column="1" Grid.Row="1" Name="TextBox1" TextWrapping="Wrap" Grid.ColumnSpan="3" Grid.RowSpan="3">
          </TextBox>
        <TextBox Grid.Column="5" Grid.Row="1" Name="TextBox2" TextWrapping="Wrap" Grid.ColumnSpan="3" Grid.RowSpan="3">
        </TextBox>
        <Button Grid.Column="1" Grid.Row="7" Name="Button1">Convert</Button>
        <RadioButton Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="5" Margin="0,0,5,0" Name="RadioButton1" IsChecked="True">Hec</RadioButton>
        <RadioButton Grid.Column="3" Grid.Row="5" Name="RadioButton2">Dec</RadioButton>
        <RadioButton Grid.Column="5" Grid.Row="5" Margin="0.03,0,0,0" Name="RadioButton3">Oct</RadioButton>
        <RadioButton Grid.Column="7" Grid.Row="5" Margin="0,0,21.666,0" Name="RadioButton4">Bin</RadioButton>
    </Grid>
</Window>

Исходный код:Window1.xaml.vb

Class Window1
    Dim pr As Integer = 16

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
        Dim sm As Integer
        Dim nm As Integer
        Dim txt As String
        Dim tm As String
        TextBox2.Text = ""
        txt = TextBox1.Text
        ProgressBar1.Maximum = txt.Length - 1
        For sm = 0 To txt.Length - 1
            tm = txt(sm)
            For nm = 0 To 255
                If tm = Chr(nm) Then TextBox2.Text += " " + Convert.ToString(nm, pr)
            Next nm
            ProgressBar1.Value = sm
        Next sm
    End Sub

    Private Sub RadioButton1_Checked(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles RadioButton1.Checked
        pr = 16
    End Sub

    Private Sub RadioButton2_Checked(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles RadioButton2.Checked
        pr = 10
    End Sub

    Private Sub RadioButton3_Checked(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles RadioButton3.Checked
        pr = 8
    End Sub

    Private Sub RadioButton4_Checked(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles RadioButton4.Checked
        pr = 2
    End Sub
End Class

Вот так это все выглядит:

Преобразователь текста на MS Visual Basic.NET 9 (Framework 3.5 WPF)




Похожие статьи: