0 Replies - 1010 Views - Last Post: 31 December 2018 - 12:34 PM

#1 hexagod   User is offline

  • 😂😂😂
  • member icon

Reputation: 31
  • View blog
  • Posts: 577
  • Joined: 29-October 16

SubString Finder Program

Posted 31 December 2018 - 12:34 PM

Hey guys,
I often am looking to extract characters using the SubString method in C# and VC++ .. I created this little program to show the extracted substr and ints and plan on adding more features to it.

I'd like to add a reverse int finder from substring but I just whipped this up as alpha 1.

Not sure if anyone would find this useful or not



in Mainwindow.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace subStringFinder
{
    /// <summary>
    /// Interaction logic for Mainwindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        /*app by hexagod*/

        static int posInt;

        static int lenInt;

        private void StringTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                subStrTextBox.Text = stringTextBox.Text.Substring(posInt, lenInt);
            }
            catch (Exception ex)
            {
                statusTextBox.Text = ex.ToString();
            }
        }

        private void PosTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                posInt = Int32.Parse(posTextBox.Text);

            }
            catch (Exception ex)
            {
                statusTextBox.Text = ex.ToString();
                return;
            }
            try
            {
                subStrTextBox.Text = stringTextBox.Text.Substring(posInt, lenInt);


            }
            catch (Exception ex)
            {
                statusTextBox.Text = ex.ToString();
                return;
            }
            subStrTextBox.Text = stringTextBox.Text.Substring(posInt, lenInt);

        }

        private void LengthTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                lenInt = Int32.Parse(lengthTextBox.Text);
                subStrTextBox.Text = stringTextBox.Text.Substring(posInt, lenInt);

            }
            catch (Exception ex)
            {
                statusTextBox.Text = ex.ToString();
                return;
            }
            try
            {
                subStrTextBox.Text = stringTextBox.Text.Substring(posInt, lenInt);


            }
            catch (Exception ex)
            {
                statusTextBox.Text = ex.ToString();
                return;
            }
            subStrTextBox.Text = stringTextBox.Text.Substring(posInt, lenInt);

        }
    }
}




in Mainwindow.xaml

<Window x:Class="subStringFinder.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:subStringFinder"
        mc:Ignorable="d"
        Title="MainWindow" Height="167" Width="585">
    <Grid>
        <Label Content="&gt;&gt;SubString&gt;&gt;" HorizontalAlignment="Left" Margin="11,82,0,0" VerticalAlignment="Top" FontFamily="Old English Text MT"/>
        <TextBox x:Name="posTextBox" HorizontalAlignment="Left" Height="23" Margin="107,26,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="28" TextChanged="PosTextBox_TextChanged"/>
        <TextBox x:Name="lengthTextBox" HorizontalAlignment="Left" Height="23" Margin="140,26,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="28" TextChanged="LengthTextBox_TextChanged"/>
        <TextBox x:Name="stringTextBox" HorizontalAlignment="Left" Height="23" Margin="107,54,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="214" TextChanged="StringTextBox_TextChanged"/>
        <Label Content="string" HorizontalAlignment="Left" Margin="58,54,0,0" VerticalAlignment="Top"/>
        <TextBox x:Name="subStrTextBox" HorizontalAlignment="Left" Height="23" Margin="107,82,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="214"/>
        <Label Content="pos" HorizontalAlignment="Left" Margin="106,0,0,0" VerticalAlignment="Top"/>
        <Label Content="length" HorizontalAlignment="Left" Margin="140,0,0,0" VerticalAlignment="Top"/>
        <TextBox x:Name="statusTextBox" HorizontalAlignment="Left" Height="86" Margin="335,19,0,0" TextWrapping="Wrap" Text="status" VerticalAlignment="Top" Width="205"/>

    </Grid>
</Window>



on github:

https://github.com/h...ubString_Finder

the exe

hxxps://github.com/hexag0d/subString_Finder/blob/master/subStringFinder/bin/Release/subStringFinder.exe

:chinese:

Is This A Good Question/Topic? 0
  • +

Page 1 of 1