2017-03-15 5 views
0

프로그래밍을 처음 사용합니다. 나는 학교에서 시각적 기본에 대해 배우고있다.특정 문자 다음에 오는 모든 것을 제거하십시오. vb

VB에서 특정 문자 뒤에 모든 것을 제거 할 수 있습니까? 내가하고 싶었던 무엇

은 다음과 같습니다, 텍스트 상자에 내 사용자 입력

는 텍스트 내 프로그램에서

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

, 내가하자 대담한 편지에서 줄을 한 줄의 텍스트를 모두 제거 텍스트과 유사합니다. 그리고 특정 문자 뒤에 불필요한 부분을 제거하는 방법을 생각할 수 없습니다.

내 코드는 다음과 같습니다. 두 개의 텍스트 상자가 있습니다. 사용자가 textbox1에 텍스트를 입력하면 결과가 textbox2에 저장됩니다.

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

당신은 무엇을 시도? 스택 오버플로는 무료 코딩 서비스가 아닙니다. "여기에 코드가 필요합니다"대신에 당신이 시도한 것을 말할 수 있습니다. Visual Basic에는 문자열 조작 (예 : 수행하려는 작업) 예제가 많이 있습니다. 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 = vs.110) .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 

엔드 모듈

관련 문제