if there is any string in a given format like as "company
name employeecode date" then we have to fetch employeecode
form string
for ex-string is "capgemini12345june2013" then we have to
fetch 12345 by using vb script so guys how can we do that
please reply it.

Answers were Sorted based on User's Feedback



if there is any string in a given format like as "company name employeecode date" then we..

Answer / suman

Str = "capgemini12345une2013"
Dim i, j
For i = 1 to Len(Str)
If isnumeric(Mid(Str, i, 1)) Then
Exit For
End If
Next
MsgBox i

For j = i to Len(Str)
If not isnumeric(Mid(Str, j, 1)) Then
Exit For
End If
Next
MsgBox j
MsgBox Mid(Str, i, (j - i))

Is This Answer Correct ?    5 Yes 0 No

if there is any string in a given format like as "company name employeecode date" then we..

Answer / abhijit bongale

Option Explicit

Dim Str : Str = "capgemini12345june2013"
Dim i, j

For i = 1 to Len(Str)
If Asc(Mid(Str, i, 1)) >= 48 AND Asc(Mid
(Str, i, 1)) <= 57 Then
Exit For
End If
Next

MsgBox i

For j = i to Len(Str)
If (Asc(Mid(Str, j, 1)) >= 65 AND Asc(Mid
(Str, j, 1)) <= 90) OR (Asc(Mid(Str, j, 1)) >= 97 AND Asc
(Mid(Str, j, 1)) <= 122) Then
Exit For
End If
Next

MsgBox j

MsgBox Mid(Str, i, (j - i))

Set Str = Nothing

Is This Answer Correct ?    1 Yes 1 No

if there is any string in a given format like as "company name employeecode date" then we..

Answer / sriraja

str="capgemini12345june2016"
strsplit=split(str,"june")
convstr=cstr(strsplit(0))
for i=1 to len(convstr)
strmid=mid(convstr,i,1)
if isnumeric(strmid)=true Then
temp=temp&strmid
End if
Next
Print temp

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More VB Script Interview Questions

Am working with web application. i faced one senario. i.e, webpage having webtable having two coloumns, in that first coloumn is for serial no and second coloumn is for mac address link, now i want to get first row second coloumn value, that having macaddress as link. Please help me how to get that link?

2 Answers  


Mention what is the difference between vbscript and vba?

0 Answers  


Inorder to avoid Message box while writing script which alternative method can be used?

1 Answers  


write a vb script to display the code "vbscripting" alphabet by alphabet(i e 1st v then b and up to g)

2 Answers  


what is inner join? what is outer join? what is a constraint? tell me about rdbms? tell me about acid properties?

0 Answers   Estuate,






Write a VB Script to count blank Lines in a notepad

2 Answers   IBM,


What are class properties?

0 Answers  


What is the purpose of the err object in the vbscript language?

0 Answers  


How are arrays declared in the vbscript language?

0 Answers  


what is fire event method in qtp?

3 Answers   TCS,


How to write VB script for login module?

0 Answers  


How are values assigned to the variables in the vbscript language?

0 Answers  


Categories