Opening an cmd line from access form

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
 
R

Rob Oldfield

If you wanted to do it the 'correct' way then I'd say that you should tell
vb.net to create a dll that you then reference in your Access app.

Having said that, I haven't got a clue how you would do that... and if I
just wanted a working system I'd just modify the .net to write relevant
values to the registry/an .ini file/an mdb/anywhere in fact that Access can
directly read.
 
G

Guest

Hi Rob,
thanks for your fast reply!
I succeded now in creatin a dll file. I looked at the help file and find out
that writing vbc /target:libray cas.vb created a CAS.dll

But now I do not know what to do with it. Could you please advise?

Thanks again for you help.
KR
JOhannes
 
R

Rob Oldfield

Nope. Not a clue. You'd be best off asking in a vb.net group about how to
access the results from a dll. (..or just write it somewhere accessible as
before....)
 
G

Guest

Hi Rob, thanks.
I do not know how to make .net write to a file accessible to Access , eg. an
ini file.
So if you know the code please advise - othervise thanks for your help.
It was a helpfull -as I did not know how to solve the problem.
KR
Johannes

"Rob Oldfield" skrev:
 
R

Rob Oldfield

I don't have any code to hand, but look at the streamreader and streamwriter
classes to read/write to a text file. You could also just set up a data
adapter to read/write from Jet... i.e. an mdb
 
G

Guest

Thanks Rob for your time.
I will try the streamwriter.
KR
Johannes

"Rob Oldfield" skrev:
 
G

Guest

I found out - that ending the code with a readline () keeps the cmd-prompt
open...
:blush:)

"CMD" skrev:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top