set atom = New AtomicTable
atom.selection "symbol=He"
wscript.echo atom.Name & vbCrLf & atom.Symbol & vbCrLf & atom.number
atom.selection "name=Neodymium"
wscript.echo atom.Name & vbCrLf & atom.Symbol & vbCrLf & atom.number
Class AtomicTable
dim table
dim m_Number, m_Symbol, m_Name, m_Weight
private sub class_initialize
InitializeTable
end sub
public property get Number
Number = m_Number
end property
public property get Symbol
Symbol = m_Symbol
end property
public property get Name
Name = m_Name
end property
public property get Weight
Weight = m_Weight
end property
public sub selection(element)
If CBool(InStr(element, "=")) Then
s = split(lcase(element), "=")
s(0) = trim(s(0)):s(1) = trim(s(1))
Select case s(0)
Case "number"
m_number = s(0)
m_symbol = elements(s(0))(1)
m_name = elements(s(0))(2)
m_Weight = elements(s(0))(3)
case "symbol"
LookupElement 1, s(1)
case "name"
LookupElement 2, s(1)
case "weight"
LookupElement 3, s(1)
case else
err.raise 599, "AtomicTable.selection", _
"property " & s(0) & " not found in " & element & "."
end select
Else
m_number = element
m_symbol = elements(element)(1)
m_name = elements(element)(2)
m_Weight = elements(element)(3)
End If
end sub
private sub LookupElement(category, id)
'does the actual selection via a crude linear
' search
dim i
for i = 1 to ubound(table)
if table(i)(category) = id then
m_number = i
m_symbol = table(i)(1)
m_name = table(i)(2)
m_Weight = table(i)(3)
' we're done, just leave
exit sub
end if
next
end sub
sub InitializeTable
'function automatically generated 2002.12.25 23:51:16
redim table(114)
' there are better ways to do this; probably an ADO
' recordset would scream at this job...
table(1) = Array(1, "h", "hydrogen", 1.007947)
table(2) = Array(2, "he", "helium", 4.0026022)
table(3) = Array(3, "li", "lithium", 6.9412)
table(4) = Array(4, "be", "beryllium", 9.0121823)
table(5) = Array(5, "b", "boron", 10.8117)
table(6) = Array(6, "c", "carbon", 12.01078)
table(7) = Array(7, "n", "nitrogen", 14.00672)
table(8) = Array(8, "o", "oxygen", 15.99943)
table(9) = Array(9, "f", "fluorine", 18.99840325)
table(10) = Array(10, "ne", "neon", 20.17976)
table(11) = Array(11, "na", "sodium", 22.9897702)
table(12) = Array(12, "mg", "magnesium", 24.30506)
table(13) = Array(13, "al", "aluminium", 26.9815382)
table(14) = Array(14, "si", "silicon", 28.08553)
table(15) = Array(15, "p", "phosphorus", 30.9737612)
table(16) = Array(16, "s", "sulfur", 32.0655)
table(17) = Array(17, "cl", "chlorine", 35.4532)
table(18) = Array(18, "ar", "argon", 39.9481)
table(19) = Array(19, "k", "potassium", 39.09831)
table(20) = Array(20, "ca", "calcium", 40.0784)
table(21) = Array(21, "sc", "scandium", 44.9559108)
table(22) = Array(22, "ti", "titanium", 47.8671)
table(23) = Array(23, "v", "vanadium", 50.94151)
table(24) = Array(24, "cr", "chromium", 51.99616)
table(25) = Array(25, "mn", "manganese", 54.9380499)
table(26) = Array(26, "fe", "iron", 55.8452)
table(27) = Array(27, "co", "cobalt", 58.9332009)
table(28) = Array(28, "ni", "nickel", 58.69342)
table(29) = Array(29, "cu", "copper", 63.5463)
table(30) = Array(30, "zn", "zinc", 65.4094)
table(31) = Array(31, "ga", "gallium", 69.7231)
table(32) = Array(32, "ge", "germanium", 72.641)
table(33) = Array(33, "as", "arsenic", 74.921602)
table(34) = Array(34, "se", "selenium", 78.963)
table(35) = Array(35, "br", "bromine", 79.9041)
table(36) = Array(36, "kr", "krypton", 83.7982)
table(37) = Array(37, "rb", "rubidium", 85.46783)
table(38) = Array(38, "sr", "strontium", 87.621)
table(39) = Array(39, "y", "yttrium", 88.905852)
table(40) = Array(40, "zr", "zirconium", 91.2242)
table(41) = Array(41, "nb", "niobium", 92.906382)
table(42) = Array(42, "mo", "molybdenum", 95.942)
table(43) = Array(43, "tc", "technetium", 98)
table(44) = Array(44, "ru", "ruthenium", 101.072)
table(45) = Array(45, "rh", "rhodium", 102.905502)
table(46) = Array(46, "pd", "palladium", 106.421)
table(47) = Array(47, "ag", "silver", 107.86822)
table(48) = Array(48, "cd", "cadmium", 112.4118)
table(49) = Array(49, "in", "indium", 114.8183)
table(50) = Array(50, "sn", "tin", 118.7107)
table(51) = Array(51, "sb", "antimony", 121.7601)
table(52) = Array(52, "te", "tellurium", 127.603)
table(53) = Array(53, "i", "iodine", 126.904473)
table(54) = Array(54, "xe", "xenon", 131.2936)
table(55) = Array(55, "cs", "caesium", 132.905452)
table(56) = Array(56, "ba", "barium", 137.3277)
table(57) = Array(57, "la", "lanthanum", 138.90552)
table(58) = Array(58, "ce", "cerium", 140.1161)
table(59) = Array(59, "pr", "praseodymium", 140.907652)
table(60) = Array(60, "nd", "neodymium", 144.243)
table(61) = Array(61, "pm", "promethium", 145)
table(62) = Array(62, "sm", "samarium", 150.363)
table(63) = Array(63, "eu", "europium", 151.9641)
table(64) = Array(64, "gd", "gadolinium", 157.253)
table(65) = Array(65, "tb", "terbium", 158.925342)
table(66) = Array(66, "dy", "dysprosium", 162.5001)
table(67) = Array(67, "ho", "holmium", 164.930322)
table(68) = Array(68, "er", "erbium", 167.2593)
table(69) = Array(69, "tm", "thulium", 168.934212)
table(70) = Array(70, "yb", "ytterbium", 173.043)
table(71) = Array(71, "lu", "lutetium", 174.9671)
table(72) = Array(72, "hf", "hafnium", 178.492)
table(73) = Array(73, "ta", "tantalum", 180.94791)
table(74) = Array(74, "w", "tungsten", 183.841)
table(75) = Array(75, "re", "rhenium", 186.2071)
table(76) = Array(76, "os", "osmium", 190.233)
table(77) = Array(77, "ir", "iridium", 192.2173)
table(78) = Array(78, "pt", "platinum", 195.0782)
table(79) = Array(79, "au", "gold", 196.966552)
table(80) = Array(80, "hg", "mercury", 200.592)
table(81) = Array(81, "tl", "thallium", 204.38332)
table(82) = Array(82, "pb", "lead", 207.21)
table(83) = Array(83, "bi", "bismuth", 208.980382)
table(84) = Array(84, "po", "polonium", 209)
table(85) = Array(85, "at", "astatine", 210)
table(86) = Array(86, "rn", "radon", 222)
table(87) = Array(87, "fr", "francium", 223)
table(88) = Array(88, "ra", "radium", 226)
table(89) = Array(89, "ac", "actinium", 227)
table(90) = Array(90, "th", "thorium", 232.03811)
table(91) = Array(91, "pa", "protactinium", 231.035882)
table(92) = Array(92, "u", "uranium", 238.028913)
table(93) = Array(93, "np", "neptunium", 237)
table(94) = Array(94, "pu", "plutonium", 244)
table(95) = Array(95, "am", "americium", 243)
table(96) = Array(96, "cm", "curium", 247)
table(97) = Array(97, "bk", "berkelium", 247)
table(98) = Array(98, "cf", "californium", 251)
table(99) = Array(99, "es", "einsteinium", 252)
table(100) = Array(100, "fm", "fermium", 257)
table(101) = Array(101, "md", "mendelevium", 258)
table(102) = Array(102, "no", "nobelium", 259)
table(103) = Array(103, "lr", "lawrencium", 262)
table(104) = Array(104, "rf", "rutherfordium", 261)
table(105) = Array(105, "db", "dubnium", 262)
table(106) = Array(106, "sg", "seaborgium", 266)
table(107) = Array(107, "bh", "bohrium", 264)
table(108) = Array(108, "hs", "hassium", 277)
table(109) = Array(109, "mt", "meitnerium", 268)
table(110) = Array(110, "uun", "ununnilium", 281)
table(111) = Array(111, "uuu", "unununium", 272)
table(112) = Array(112, "uub", "ununbium", 285)
table(114) = Array(114, "uuq", "ununquadium", 289)
end sub
end class