2017-03-15 11 views
0

プログラミングが初めてです。私は学校のビジュアルベーシックについて学んでいます。特定の文字の後ろにあるすべてを削除するvb

vbベーシックで特定の文字の後にすべてを削除することは可能ですか?

私がやりたいこと

がある:太字で私のプログラムで

テキスト

background-image: url("url =** example.com %2A%7Ehmac%3D0da31302030394a84ae567e54f5cce15b3e18133&_nc_hash=AQCFmBtOnL2EgdP6** 

をすべてを削除し、私はライン、テキストボックスに自分のユーザー入力テキストの行を聞かせてテキストに似ています。そして、特定の文字の後に不要な部分を取り除く方法を考えることはできません。

ここに私のコードがあります。私は2つのテキストボックスを持っており、ユーザーはtextbox1にテキストを入れ、結果はtextbox2になります。

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 
    "i need code here" 
End Sub 
+3

あなたは何を試してみましたか?スタックオーバーフローは無料のコーディングサービスではありません。 「ここにコードが必要です」の代わりに、おそらくあなたが試したことを言うことができます。 Visual Basicでは、文字列操作(これはあなたがやろうとしていることです)の多くの例がWeb上にあります。 Google検索をお試しください。特定の質問がある場合は、Stack Overflowが役立ちます。 –

+0

部分文字列とIndexOfを検索します。https://msdn.microsoft.com/en-us/library/aka44szs(v=vs.110).aspx https://msdn.microsoft.com/en-us/library/k8b1470s( v = 1.10).aspx – obl

答えて

0

あなたは(与えられた文字のインデックス/位置を取得する)substing(&から指定されたインデックス/位置に文字列を分割)し、機能の指標で作業することができます。 あなたのコードは、このようになります。

Module Module1 
Sub Main() 
    Use this string literal for the demonstration. 
    Dim literal As String = "CatDogFence" 
    Dim pos as Integer 

    ' Gives you the position of the D (from DOG) 
    ' - 1 because we dont want to see the D of dog 

    pos = literal.IndexOf("D") -1 

    ' Take the first three characters into a new string. 
    ' ... Use the Substring method. 

    Dim substring As String = literal.Substring(0, pos) 

    ' substring will contain Cat , because we get from the substring 
    'everything from position 0 (the start) to 3 (the D of Dog) 
    ' Write the results to the screen. 

    Console.WriteLine("Substring: {0}", substring) 
End Sub 

エンドモジュール

関連する問題