Note that there are some explanatory texts on larger screens.

plurals
  1. POFinding String of Substring in VB without using library function
    primarykey
    data
    text
    <p>I am little bit confused in this program. I am new to Visual Basic but intermediate to C. Actually I want to get sub-string of string without using library function of Visual Basic. Here is the C source code I also given my VB code too. 1.The Program will get two inputs from user i.e A &amp; B 2. Than Find the substring from B. 3. Finally Print the result.</p> <pre class="lang-c prettyprint-override"><code>int i,j=0,k=0,substr=0; for(i=0;i&lt;strlen(a);i++) { if(a[i]==b[j]) { j++; if(b[j]==0) { printf("second string is substring of first one"); substr=1; break; } } } for(i=0;i&lt;strlen(b);i++) { if(b[i]==a[k]) { k++; if(a[k]==0) { printf(" first string is substring of second string"); substr=1; break ; } } } if(substr==0) { printf("no substring present"); } </code></pre> <p>While my code is </p> <pre class="lang-vb prettyprint-override"><code> Dim a As String Dim b As String a = InputBox("Enter First String", a) b = InputBox("Enter 2nd String", b) Dim i As Integer Dim j As Integer = 0 Dim k As Integer = 0 Dim substr As Integer = 0 For i = 0 To a.Length - 1 If a(i) = b(j) Then j += 1 If b(j) = 0 Then MsgBox("second string is substring of first one") substr = 1 Exit For End If End If Next i For i = 0 To b.Length - 1 If b(i) = a(k) Then k += 1 If a(k) = 0 Then MsgBox(" first string is substring of second string") substr = 1 Exit For End If End If Next i If substr = 0 Then MsgBox("no substring present") End If End Sub </code></pre> <p>While compiling it gives following debugging errors.</p> <pre><code> Line Col Error 1 Operator '=' is not defined for types 'Char' and 'Integer'. 17 24 Error 2 Operator '=' is not defined for types 'Char' and 'Integer'. 27 24 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload