G
Guest
Hi, I have created a vb.net application validating a CAS-number (chemistry).
I want to access this program from a form in access. It is possible to open a
external program using the event procedure, but cmd. closes after the program
has run.
When it does that I do not get the answer from the calculation.
I tried to make the validation work using a vb code in an event procedure -
but I did not succeed.
So I hope you will help me with either of the following:
*to know how to run a cmd application whitout shutting it down immidiately
after is has run.
*Or help to tell me how to translate my vb.net into vb taking the input from
a table instead of using the ReadLine()
My code is the below.
Thx in anticipation.
option strict on
imports system, system.console
Public class VBdemo
Shared Sub Main()
Dim CAS as string, CS as Int32, i,j,k,l,m,n,o,p,q,x,y,z as int32
try
Writeline("Type CAS-number")
CAS = readline()
CS = CAS.length
select case CS
Case 7
i = convert.ToInt32 (cas.Substring(6,1))
j = convert.ToInt32 (cas.Substring(4,1))
k = convert.ToInt32 (cas.Substring(3,1))
l = convert.ToInt32 (cas.Substring(1,1))
m = convert.ToInt32 (cas.Substring(0,1))
x = 1*j+2*k+3*l+4*m
y = x mod 10
if y = i
writeline ("CAS-number OK")
else
writeline ("Not a CAS-number, Control digit does not match")
end if
Case 8
i = convert.ToInt32 (cas.Substring(7,1))
j = convert.ToInt32 (cas.Substring(5,1))
k = convert.ToInt32 (cas.Substring(4,1))
l = convert.ToInt32 (cas.Substring(2,1))
m = convert.ToInt32 (cas.Substring(1,1))
n = convert.ToInt32 (cas.Substring(0,1))
x = 1*j+2*k+3*l+4*m+5*n
y = x mod 10
if y = i
writeline ("CAS-number OK")
else
writeline ("Not a CAS-number, Control digit does not match")
end if
Case 9
i = convert.ToInt32 (cas.Substring(8,1))
j = convert.ToInt32 (cas.Substring(6,1))
k = convert.ToInt32 (cas.Substring(5,1))
l = convert.ToInt32 (cas.Substring(3,1))
m = convert.ToInt32 (cas.Substring(2,1))
n = convert.ToInt32 (cas.Substring(1,1))
o = convert.ToInt32 (cas.Substring(0,1))
x = 1*j+2*k+3*l+4*m+5*n+6*o
y = x mod 10
if y = i
writeline ("CAS-number OK")
else
writeline ("Not a CAS-number, Control digit does not match")
end if
Case 10
i = convert.ToInt32 (cas.Substring(9,1))
j = convert.ToInt32 (cas.Substring(7,1))
k = convert.ToInt32 (cas.Substring(6,1))
l = convert.ToInt32 (cas.Substring(4,1))
m = convert.ToInt32 (cas.Substring(3,1))
n = convert.ToInt32 (cas.Substring(2,1))
o = convert.ToInt32 (cas.Substring(1,1))
p = convert.ToInt32 (cas.Substring(0,1))
x = 1*j+2*k+3*l+4*m+5*n+6*o+7*p
y = x mod 10
if y = i
writeline ("CAS-number OK")
else
writeline ("Not a CAS-number, Control digit does not match")
end if
Case 11
i = convert.ToInt32 (cas.Substring(10,1))
j = convert.ToInt32 (cas.Substring(8,1))
k = convert.ToInt32 (cas.Substring(7,1))
l = convert.ToInt32 (cas.Substring(5,1))
m = convert.ToInt32 (cas.Substring(4,1))
n = convert.ToInt32 (cas.Substring(3,1))
o = convert.ToInt32 (cas.Substring(2,1))
p = convert.ToInt32 (cas.Substring(1,1))
q = convert.ToInt32 (cas.Substring(0,1))
x = 1*j+2*k+3*l+4*m+5*n+6*o+7*p
y = x mod 10
if y = i
writeline ("CAS-number OK")
else
writeline ("Not a CAS-number, Control digit does not match")
end if
Case 12,13,14,15,16
Writeline ("Number is too long - has to be max 9 digits")
end select
catch
Writeline ("The number must be entered in this way: xxxxxx-xx-x")
end try
end sub
end class
I want to access this program from a form in access. It is possible to open a
external program using the event procedure, but cmd. closes after the program
has run.
When it does that I do not get the answer from the calculation.
I tried to make the validation work using a vb code in an event procedure -
but I did not succeed.
So I hope you will help me with either of the following:
*to know how to run a cmd application whitout shutting it down immidiately
after is has run.
*Or help to tell me how to translate my vb.net into vb taking the input from
a table instead of using the ReadLine()
My code is the below.
Thx in anticipation.
option strict on
imports system, system.console
Public class VBdemo
Shared Sub Main()
Dim CAS as string, CS as Int32, i,j,k,l,m,n,o,p,q,x,y,z as int32
try
Writeline("Type CAS-number")
CAS = readline()
CS = CAS.length
select case CS
Case 7
i = convert.ToInt32 (cas.Substring(6,1))
j = convert.ToInt32 (cas.Substring(4,1))
k = convert.ToInt32 (cas.Substring(3,1))
l = convert.ToInt32 (cas.Substring(1,1))
m = convert.ToInt32 (cas.Substring(0,1))
x = 1*j+2*k+3*l+4*m
y = x mod 10
if y = i
writeline ("CAS-number OK")
else
writeline ("Not a CAS-number, Control digit does not match")
end if
Case 8
i = convert.ToInt32 (cas.Substring(7,1))
j = convert.ToInt32 (cas.Substring(5,1))
k = convert.ToInt32 (cas.Substring(4,1))
l = convert.ToInt32 (cas.Substring(2,1))
m = convert.ToInt32 (cas.Substring(1,1))
n = convert.ToInt32 (cas.Substring(0,1))
x = 1*j+2*k+3*l+4*m+5*n
y = x mod 10
if y = i
writeline ("CAS-number OK")
else
writeline ("Not a CAS-number, Control digit does not match")
end if
Case 9
i = convert.ToInt32 (cas.Substring(8,1))
j = convert.ToInt32 (cas.Substring(6,1))
k = convert.ToInt32 (cas.Substring(5,1))
l = convert.ToInt32 (cas.Substring(3,1))
m = convert.ToInt32 (cas.Substring(2,1))
n = convert.ToInt32 (cas.Substring(1,1))
o = convert.ToInt32 (cas.Substring(0,1))
x = 1*j+2*k+3*l+4*m+5*n+6*o
y = x mod 10
if y = i
writeline ("CAS-number OK")
else
writeline ("Not a CAS-number, Control digit does not match")
end if
Case 10
i = convert.ToInt32 (cas.Substring(9,1))
j = convert.ToInt32 (cas.Substring(7,1))
k = convert.ToInt32 (cas.Substring(6,1))
l = convert.ToInt32 (cas.Substring(4,1))
m = convert.ToInt32 (cas.Substring(3,1))
n = convert.ToInt32 (cas.Substring(2,1))
o = convert.ToInt32 (cas.Substring(1,1))
p = convert.ToInt32 (cas.Substring(0,1))
x = 1*j+2*k+3*l+4*m+5*n+6*o+7*p
y = x mod 10
if y = i
writeline ("CAS-number OK")
else
writeline ("Not a CAS-number, Control digit does not match")
end if
Case 11
i = convert.ToInt32 (cas.Substring(10,1))
j = convert.ToInt32 (cas.Substring(8,1))
k = convert.ToInt32 (cas.Substring(7,1))
l = convert.ToInt32 (cas.Substring(5,1))
m = convert.ToInt32 (cas.Substring(4,1))
n = convert.ToInt32 (cas.Substring(3,1))
o = convert.ToInt32 (cas.Substring(2,1))
p = convert.ToInt32 (cas.Substring(1,1))
q = convert.ToInt32 (cas.Substring(0,1))
x = 1*j+2*k+3*l+4*m+5*n+6*o+7*p
y = x mod 10
if y = i
writeline ("CAS-number OK")
else
writeline ("Not a CAS-number, Control digit does not match")
end if
Case 12,13,14,15,16
Writeline ("Number is too long - has to be max 9 digits")
end select
catch
Writeline ("The number must be entered in this way: xxxxxx-xx-x")
end try
end sub
end class