-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMMCONV.FRM
1916 lines (1596 loc) · 62.8 KB
/
MMCONV.FRM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "richtx32.ocx"
Begin VB.Form frmMMConvert
Caption = "Mole/Mass Converter and Dilution Calculator"
ClientHeight = 6660
ClientLeft = 540
ClientTop = 1395
ClientWidth = 10515
ForeColor = &H80000008&
HelpContextID = 3040
Icon = "MMCONV.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
PaletteMode = 1 'UseZOrder
ScaleHeight = 6660
ScaleWidth = 10515
Tag = "11000"
Begin VB.Frame fraMZConversion
Height = 1770
Left = 120
TabIndex = 13
Tag = "12410"
Top = 4750
Width = 6315
Begin VB.TextBox txtMZHighAlt
Height = 315
Left = 5040
Locked = -1 'True
TabIndex = 31
Tag = "11100"
Text = "100"
Top = 1320
Width = 1095
End
Begin VB.TextBox txtMZLowAlt
Height = 315
Left = 3840
Locked = -1 'True
TabIndex = 30
Tag = "11100"
Text = "100"
Top = 1320
Width = 1095
End
Begin VB.TextBox txtMZHigh
Height = 315
Left = 5040
Locked = -1 'True
TabIndex = 29
Tag = "11100"
Text = "100"
Top = 960
Width = 1095
End
Begin VB.TextBox txtMZLow
Height = 315
Left = 3840
Locked = -1 'True
TabIndex = 28
Tag = "11100"
Text = "100"
Top = 960
Width = 1095
End
Begin VB.ComboBox cboMassError
Height = 315
Left = 5040
Style = 2 'Dropdown List
TabIndex = 25
Tag = "11020"
Top = 240
Width = 1125
End
Begin VB.TextBox txtMassError
Height = 315
Left = 4200
TabIndex = 24
Tag = "11100"
Text = "100"
Top = 240
Width = 735
End
Begin VB.ComboBox cboMH
Height = 315
Left = 120
Style = 2 'Dropdown List
TabIndex = 17
Top = 960
Width = 1600
End
Begin VB.TextBox txtMH
Height = 315
Left = 1920
TabIndex = 18
Text = "1000"
Top = 960
Width = 1200
End
Begin VB.ComboBox cboMHAlternate
Height = 315
Left = 120
Style = 2 'Dropdown List
TabIndex = 20
Top = 1320
Width = 1600
End
Begin VB.TextBox txtMHAlt
Height = 315
Left = 1920
TabIndex = 21
Text = "500.503695"
Top = 1320
Width = 1200
End
Begin VB.OptionButton optElementMode
Caption = "Isotopic"
Height = 255
HelpContextID = 4053
Index = 1
Left = 1080
TabIndex = 16
Tag = "12430"
Top = 480
Width = 1395
End
Begin VB.OptionButton optElementMode
Caption = "Average"
Height = 255
HelpContextID = 4053
Index = 0
Left = 1080
TabIndex = 15
Tag = "12425"
Top = 240
Value = -1 'True
Width = 1395
End
Begin VB.Label Label2
Alignment = 2 'Center
Caption = "m/z end"
Height = 255
Left = 5040
TabIndex = 27
Top = 720
Width = 1095
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "m/z start"
Height = 255
Left = 3840
TabIndex = 26
Top = 720
Width = 1095
End
Begin VB.Label lblMassError
Caption = "Mass Error"
Height = 255
Left = 3240
TabIndex = 23
Top = 240
Width = 1095
End
Begin VB.Label lblMHDa
Caption = "m/z"
Height = 255
Left = 3200
TabIndex = 19
Tag = "12350"
Top = 985
Width = 495
End
Begin VB.Label lblMHAltDa
Caption = "m/z"
Height = 255
Left = 3200
TabIndex = 22
Tag = "12350"
Top = 1345
Width = 495
End
Begin VB.Label lblElementMode
Caption = "Element Mode"
Height = 465
Left = 120
TabIndex = 14
Tag = "12420"
Top = 240
Width = 975
End
End
Begin VB.TextBox txtDensity
Height = 285
Left = 3240
TabIndex = 61
Tag = "11110"
Text = "1"
ToolTipText = "Density of compound"
Top = 1680
Width = 1095
End
Begin VB.CheckBox chkLinkDilutionVolumeUnits
Caption = "Link Dilution Volume Units"
Height = 405
HelpContextID = 4092
Left = 6240
TabIndex = 33
Tag = "11230"
Top = 1080
Width = 4095
End
Begin VB.CheckBox chkLinkMolarities
Caption = "&Link Initial Dilution Concentration and Convert Amounts Concentration"
Height = 405
HelpContextID = 4092
Left = 6240
TabIndex = 32
Tag = "11220"
Top = 600
Width = 3975
End
Begin VB.Frame fraConvertAmounts
Height = 2445
Left = 120
TabIndex = 1
Top = 2040
Width = 4935
Begin VB.TextBox txtConcentration
Height = 315
Left = 120
TabIndex = 10
Tag = "11130"
Text = "1"
ToolTipText = "Molarity of compound in the solvent"
Top = 1920
Width = 1095
End
Begin VB.ComboBox cboVolume
Height = 315
Left = 1320
Style = 2 'Dropdown List
TabIndex = 8
Tag = "11030"
ToolTipText = "Units of volume"
Top = 1320
Width = 1600
End
Begin VB.TextBox txtVolume
Height = 315
Left = 120
TabIndex = 7
Tag = "11120"
Text = "100"
ToolTipText = "Volume of solvent the compound is dissolved in"
Top = 1320
Width = 1095
End
Begin VB.ComboBox cboTo
Height = 315
Left = 1320
Style = 2 'Dropdown List
TabIndex = 5
Tag = "11020"
Top = 720
Width = 1600
End
Begin VB.ComboBox cboFrom
Height = 315
Left = 1320
Style = 2 'Dropdown List
TabIndex = 3
Tag = "11020"
Top = 240
Width = 1600
End
Begin VB.TextBox txtFromNum
Height = 315
Left = 120
TabIndex = 2
Tag = "11100"
Text = "1"
ToolTipText = "Amount of compound to convert from or to be dissolved in solvent"
Top = 240
Width = 1095
End
Begin VB.CommandButton cmdFindVolume
Caption = "Find &Volume"
Height = 480
Left = 3075
TabIndex = 9
Tag = "11160"
ToolTipText = "Calculate the volume using the amount and molarity"
Top = 1200
Width = 1515
End
Begin VB.CommandButton cmdFindConcentration
Caption = "Find &Concentration"
Height = 480
Left = 3075
TabIndex = 12
Tag = "11170"
ToolTipText = "Calculate the concentration using the amount and volume"
Top = 1800
Width = 1515
End
Begin VB.ComboBox cboConcentration
Height = 315
Left = 1320
Style = 2 'Dropdown List
TabIndex = 11
Tag = "7090"
Top = 1920
Width = 1600
End
Begin VB.CommandButton cmdFindAmount
Caption = "Find &Amount"
Height = 480
Left = 3075
TabIndex = 6
Tag = "11150"
ToolTipText = "Calculate the amount using the volume and molarity"
Top = 240
Width = 1515
End
Begin VB.Label lblToNum
Caption = "Label1"
Height = 255
Left = 120
TabIndex = 4
Top = 720
Width = 1095
End
End
Begin VB.Frame fraDilutionCalcs
Caption = "Dilution Calculations"
Height = 3135
Left = 5160
TabIndex = 34
Tag = "11200"
Top = 1560
Width = 5175
Begin VB.ComboBox cboDilutionMode
Height = 315
Left = 120
Style = 2 'Dropdown List
TabIndex = 35
Tag = "11210"
ToolTipText = "Quantity to find for dilution calculations"
Top = 240
Width = 3675
End
Begin VB.ComboBox cboDilutingSolventVolume
Height = 315
Left = 3360
Style = 2 'Dropdown List
TabIndex = 47
Tag = "11030"
Top = 2160
Width = 1600
End
Begin VB.TextBox txtDilutingSolventVolume
Height = 315
Left = 2160
TabIndex = 46
Tag = "11285"
Text = "12"
ToolTipText = "Volume of solvent the compound is dissolved in"
Top = 2160
Width = 1015
End
Begin VB.ComboBox cboStockSolutionVolume
Height = 315
Left = 3360
Style = 2 'Dropdown List
TabIndex = 41
Tag = "11030"
Top = 1200
Width = 1600
End
Begin VB.TextBox txtStockSolutionVolume
Height = 315
Left = 2160
TabIndex = 40
Tag = "11265"
Text = "3"
ToolTipText = "Volume of solvent the compound is dissolved in"
Top = 1200
Width = 1015
End
Begin VB.TextBox txtDilutionConcentrationInitial
Height = 315
Left = 2160
TabIndex = 37
Tag = "11255"
Text = "10"
ToolTipText = "Molarity of compound in the solvent"
Top = 720
Width = 1015
End
Begin VB.ComboBox cboDilutionConcentrationInitial
Height = 315
Left = 3360
Style = 2 'Dropdown List
TabIndex = 38
Tag = "7090"
Top = 720
Width = 1600
End
Begin VB.ComboBox cboDilutionConcentrationFinal
Height = 315
Left = 3360
Style = 2 'Dropdown List
TabIndex = 44
Tag = "7090"
Top = 1680
Width = 1600
End
Begin VB.TextBox txtTotalVolume
Height = 315
Left = 2160
TabIndex = 49
Tag = "11295"
Text = "15"
ToolTipText = "Volume of solvent the compound is dissolved in"
Top = 2640
Width = 1015
End
Begin VB.ComboBox cboTotalVolume
Height = 315
Left = 3360
Style = 2 'Dropdown List
TabIndex = 50
Tag = "11030"
Top = 2640
Width = 1600
End
Begin VB.TextBox txtDilutionConcentrationFinal
Height = 315
Left = 2160
TabIndex = 43
Tag = "11275"
Text = "2"
ToolTipText = "Molarity of compound in the solvent"
Top = 1680
Width = 1015
End
Begin VB.Label lblDilutingSolventVolume
Caption = "Volume of Solvent used for &Dilution"
Height = 405
Left = 120
TabIndex = 45
Tag = "11280"
Top = 2120
Width = 1905
End
Begin VB.Label lblTotalVolume
Caption = "&Total Final Volume"
Height = 405
Left = 120
TabIndex = 48
Tag = "11290"
Top = 2630
Width = 1905
End
Begin VB.Label lblDilutionConcentrationFinal
Caption = "&Final Concentration"
Height = 405
Left = 120
TabIndex = 42
Tag = "11270"
Top = 1665
Width = 1905
End
Begin VB.Label lblStockSolutionVolume
Caption = "Volume of &Stock Solution"
Height = 405
Left = 120
TabIndex = 39
Tag = "11260"
Top = 1185
Width = 1905
End
Begin VB.Label lblDilutionConcentrationInitial
Caption = "&Initial Concentration"
Height = 405
Left = 120
TabIndex = 36
Tag = "11250"
Top = 705
Width = 1905
End
End
Begin VB.ComboBox cboAction
Height = 315
Left = 120
Style = 2 'Dropdown List
TabIndex = 0
Tag = "11010"
ToolTipText = "Perform conversions between different amounts of compound or perform molarity-related calculations"
Top = 1680
Width = 2955
End
Begin VB.Frame fraWeightSource
BorderStyle = 0 'None
Caption = "Weight Source"
Height = 1575
Left = 240
TabIndex = 52
Top = 0
Width = 5655
Begin VB.TextBox txtMWTValue
Height = 285
Left = 720
Locked = -1 'True
TabIndex = 63
Tag = "7600"
Text = "100"
ToolTipText = "Enter custom numerical mass for use in computations"
Top = 1200
Width = 1215
End
Begin VB.TextBox txtCustomMass
Height = 285
Left = 3120
TabIndex = 55
Tag = "7600"
Text = "100"
ToolTipText = "Enter custom numerical mass for use in computations"
Top = 1200
Width = 1575
End
Begin VB.OptionButton optWeightSource
Caption = "&Enter custom numerical mass"
Height = 255
HelpContextID = 4010
Index = 1
Left = 0
TabIndex = 54
Tag = "7760"
Top = 240
Width = 5475
End
Begin VB.OptionButton optWeightSource
Caption = "&Use mass of compound in current formula"
Height = 255
HelpContextID = 4010
Index = 0
Left = 0
TabIndex = 53
Tag = "7750"
Top = 0
Value = -1 'True
Width = 5475
End
Begin RichTextLib.RichTextBox rtfCurrentFormula
Height = 495
Left = 2040
TabIndex = 56
TabStop = 0 'False
Top = 600
Width = 3615
_ExtentX = 6376
_ExtentY = 873
_Version = 393217
Enabled = 0 'False
MultiLine = 0 'False
Appearance = 0
TextRTF = $"MMCONV.frx":08CA
End
Begin VB.Label lblCustomMass
Caption = "Custom Mass:"
Height = 255
Left = 2040
TabIndex = 57
Tag = "7480"
Top = 1230
Width = 2175
End
Begin VB.Label lblFormula
Caption = "Current Formula is"
Height = 255
Left = 120
TabIndex = 60
Tag = "7460"
Top = 720
Width = 1815
End
Begin VB.Label lblMWT
Caption = "MW ="
Height = 255
Left = 120
TabIndex = 59
Tag = "7470"
Top = 1230
Width = 1335
End
Begin VB.Label lblCustomMassUnits
Caption = "g/mole"
Height = 255
Left = 4800
TabIndex = 58
Tag = "7570"
Top = 1200
Width = 1095
End
End
Begin VB.CommandButton cmdOK
Cancel = -1 'True
Caption = "Cl&ose"
Height = 360
Left = 6720
TabIndex = 51
Tag = "4000"
Top = 5520
Width = 1035
End
Begin VB.Label lblDensity
Caption = "g/mL"
Height = 255
Left = 4365
TabIndex = 62
Tag = "11080"
Top = 1680
Width = 615
End
End
Attribute VB_Name = "frmMMConvert"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Enum mmaMoleMassActionConstants
mmaConvertAmounts = 0
mmaFindConcentration
mmaDilutionCalculations
End Enum
' Constants for cboDilutionMode Combo Box on frmMMConvert
Private Enum dmDilutionModeConstants
dmFindRequiredDilutionVolumes = 0
dmFindRequiredTotalVolume = 1
dmFindFinalMolarity = 2
dmFindInitialMolarity = 3
End Enum
Private Const TextBoxIDMaxIndex = 10
Private Enum mmtTextBoxIDConstants
mmtNone = 0
mmtSampleMass = 1
mmtSampleDensity = 2
mmtQuantityAmount = 3
mmtQuantityVolume = 4
mmtQuantityConcentration = 5
mmtDilutionInitialConcentration = 6
mmtDilutionVolumeStock = 7
mmtDilutionFinalConcentration = 8
mmtDilutionVolumeDilutingSolvent = 9
mmtDilutionTotalVolume = 10
End Enum
' Constants for cboMassError combo box
Private Enum meMassErrorConstants
meMZ = 0
mePPM = 1
End Enum
' Note: Other forms access this variable
Public eMassMode As mmcMassModeConstants
Private mDelayUpdateAll As Boolean ' When true, the values will not auto-update
Private mDelayUpdatingDilutionVolumes As Boolean
Private mUpdatingDilutingSolventVolume As Boolean
Private mUpdatingTotalSolventVolume As Boolean
Private mUpdatingLinkedMolarities As Boolean
Private mLastControlChanged As mmtTextBoxIDConstants ' Records the last box a key was pressed in
Private mVolumeIndexStart As Integer
Private mVolumeIndexEnd As Integer
Private objMMConverter As New MWMoleMassDilutionClass
Private Sub ComputeMassRanges()
ComputeMassRangesWork txtMH, txtMZLow, txtMZHigh
ComputeMassRangesWork txtMHAlt, txtMZLowAlt, txtMZHighAlt
End Sub
Private Sub ComputeMassRangesWork(ByRef objMH As TextBox, ByRef objMZLow As TextBox, ByRef objMZHigh As TextBox)
Dim dblMassError As Double
Dim dblMassErrorMZ As Double
Dim dblCurrentMZ As Double
dblMassError = CDblSafe(txtMassError)
dblCurrentMZ = CDblSafe(objMH.Text)
If cboMassError.ListIndex = meMassErrorConstants.mePPM Then
dblMassErrorMZ = PPMtoMass(dblMassError, dblCurrentMZ)
Else
dblMassErrorMZ = dblMassError
End If
On Error GoTo ConversionErrorHandler
objMZLow.Text = Round(objMH - dblMassErrorMZ, 6)
objMZHigh.Text = Round(objMH + dblMassErrorMZ, 6)
Exit Sub
ConversionErrorHandler:
Debug.Assert False
End Sub
Private Sub ComputeTargetConcentration()
Dim dblFromNum As Double
Dim dblToNum As Double
dblFromNum = CDblSafe(txtFromNum.Text)
dblToNum = objMMConverter.ConvertAmount(dblFromNum, cboFrom.ListIndex, cboTo.ListIndex)
If dblToNum < 0 Then
lblToNum.Caption = ""
Else
FormatLabel lblToNum, dblToNum
End If
End Sub
Private Sub ConvertSequenceMH(blnFavorMH As Boolean)
' When blnFavorMH = True then computes MHAlt using MH
' Otherwise, computes MH using MHAlt
Static blnWorking As Boolean
Dim dblMH As Double, dblMHAlt As Double
Dim intChargePrimary As Integer, intChargeAlt As Integer
If mDelayUpdateAll Then Exit Sub
If blnWorking Then Exit Sub
blnWorking = True
intChargePrimary = cboMH.ListIndex
If intChargePrimary < 0 Then intChargePrimary = 0
intChargeAlt = cboMHAlternate.ListIndex
If intChargeAlt < 0 Then intChargeAlt = 0
If blnFavorMH Then
dblMH = CDblSafe(txtMH)
If dblMH > 0 Then
dblMHAlt = objMwtWin.ConvoluteMass(dblMH, intChargePrimary, intChargeAlt)
Else
dblMHAlt = 0
End If
txtMHAlt = Round(dblMHAlt, 6)
Else
dblMHAlt = CDblSafe(txtMHAlt)
If dblMHAlt > 0 Then
dblMH = objMwtWin.ConvoluteMass(dblMHAlt, intChargeAlt, intChargePrimary)
Else
dblMH = 0
End If
txtMH = Round(dblMH, 6)
End If
ComputeMassRanges
blnWorking = False
End Sub
Private Sub FindDilutionValues(Optional blnUpdateDilutingSolventVolume As Boolean = True)
Dim dblVolumeStock As Double
Dim dblDilutingSolventVolume As Double
Dim dblTotalVolume As Double
Dim dblConcentration As Double
Static intCallLevel As Integer
' The intCallLevel variable and the following assertion are here to make sure
' we don't accidentally get into redundant loop with calling this Sub
intCallLevel = intCallLevel + 1
Debug.Assert intCallLevel = 1
' Find the desired item
' After finding the item, need to update the variable for the item just found
Select Case cboDilutionMode.ListIndex
Case dmFindRequiredDilutionVolumes
dblVolumeStock = objMMConverter.ComputeDilutionRequiredStockAndDilutingSolventVolumes(cboStockSolutionVolume.ListIndex, dblDilutingSolventVolume, cboDilutingSolventVolume.ListIndex)
If dblDilutingSolventVolume < 0 Then
txtStockSolutionVolume = ""
txtDilutingSolventVolume = ""
Else
FormatTextBox txtStockSolutionVolume, dblVolumeStock
FormatTextBox txtDilutingSolventVolume, dblDilutingSolventVolume
End If
Case dmFindFinalMolarity
dblConcentration = objMMConverter.ComputeDilutionFinalConcentration(cboDilutionConcentrationFinal.ListIndex)
FormatTextBox txtDilutionConcentrationFinal, dblConcentration
If blnUpdateDilutingSolventVolume Then UpdateDilutingSolventVolume
Case dmFindInitialMolarity
dblConcentration = objMMConverter.ComputeDilutionInitialConcentration(cboDilutionConcentrationInitial.ListIndex)
FormatTextBox txtDilutionConcentrationInitial, dblConcentration
If blnUpdateDilutingSolventVolume Then UpdateDilutingSolventVolume
Case Else ' Includes dmFindRequiredTotalVolume
dblTotalVolume = objMMConverter.ComputeDilutionTotalVolume(cboTotalVolume.ListIndex, dblDilutingSolventVolume, cboDilutingSolventVolume.ListIndex)
If dblDilutingSolventVolume <= 0 Then
txtDilutingSolventVolume = ""
Else
FormatTextBox txtDilutingSolventVolume, dblDilutingSolventVolume
End If
FormatTextBox txtTotalVolume, dblTotalVolume
End Select
UpdateDynamicDilutionFrameLabel
intCallLevel = intCallLevel - 1
mLastControlChanged = mmtNone
End Sub
Private Sub FindQuantityAmount()
Dim dblAmount As Double
dblAmount = objMMConverter.ComputeQuantityAmount(cboFrom.ListIndex)
FormatTextBox txtFromNum, dblAmount
mLastControlChanged = mmtNone
End Sub
Private Sub FindQuantityConcentration()
Dim dblConcentration As Double
dblConcentration = objMMConverter.ComputeQuantityConcentration(cboConcentration.ListIndex)
FormatTextBox txtConcentration, dblConcentration
mLastControlChanged = mmtNone
End Sub
Private Sub FindQuantityVolume()
Dim dblVolume As Double
dblVolume = objMMConverter.ComputeQuantityVolume(cboVolume.ListIndex)
FormatTextBox txtVolume, dblVolume
mLastControlChanged = mmtNone
End Sub
Private Function GetWorkingMass() As Double
If eMassMode = mmcComputedMass Then
GetWorkingMass = CDblSafe(txtMWTValue.Text)
Else
GetWorkingMass = CDblSafe(txtCustomMass.Text)
End If
End Function
Private Sub HandleDilutingSolventVolumeChange()
If cboDilutionMode.ListIndex = dmFindRequiredDilutionVolumes Or _
cboDilutionMode.ListIndex = dmFindRequiredTotalVolume Then
Exit Sub
End If
SynchronizeQuantitiesWithDLL mmtDilutionVolumeDilutingSolvent
If mUpdatingDilutingSolventVolume Then Exit Sub
UpdateTotalSolventVolume
FindDilutionValues False
End Sub
Private Sub HighlightTargetBoxes()
' Change background color of text boxes to indicate which is being found
Dim ctlThisControl As Control, strControlType As String
Dim lngHighlightedColor As Long
For Each ctlThisControl In Me.Controls
strControlType = TypeName(ctlThisControl)
If strControlType = "TextBox" Then
ctlThisControl.BackColor = QBColor(COLOR_WHITE)
End If
Next
' 7, 10, and 14 are good colors for QBColor()
lngHighlightedColor = QBColor(COLOR_COMPUTEDQUANTITY)
Select Case cboDilutionMode.ListIndex
Case dmFindRequiredTotalVolume ' Find Required Total Volume
txtDilutingSolventVolume.BackColor = lngHighlightedColor
txtTotalVolume.BackColor = lngHighlightedColor
Case dmFindFinalMolarity ' Find Final Molarity
txtDilutionConcentrationFinal.BackColor = lngHighlightedColor
Case dmFindInitialMolarity ' Find Initial Molarity
txtDilutionConcentrationInitial.BackColor = lngHighlightedColor
Case Else
' Includes case 0 ' Find Required Dilution Volumes
txtStockSolutionVolume.BackColor = lngHighlightedColor
txtDilutingSolventVolume.BackColor = lngHighlightedColor
End Select
End Sub
Private Sub UpdateDilutingSolventVolume()
Dim dblDilutingSolventVolume As Double
mUpdatingDilutingSolventVolume = True
dblDilutingSolventVolume = objMMConverter.GetDilutionVolumeDilutingSolvent(cboDilutingSolventVolume.ListIndex)
If dblDilutingSolventVolume < 0 Then
txtDilutingSolventVolume = ""
ElseIf dblDilutingSolventVolume = 0 Then
txtDilutingSolventVolume = "0"
Else
FormatTextBox txtDilutingSolventVolume, dblDilutingSolventVolume
End If
mUpdatingDilutingSolventVolume = False
End Sub
Private Sub UpdateTotalSolventVolume()
Dim dblStockSolutionVolume As Double
Dim dblDilutingSolventVolume As Double
Dim dblFinalTotalVolume As Double
mUpdatingTotalSolventVolume = True
With objMMConverter
dblStockSolutionVolume = .GetDilutionVolumeStockSolution(uevML)
dblDilutingSolventVolume = .GetDilutionVolumeDilutingSolvent(uevML)
dblFinalTotalVolume = .ConvertVolumeExtended(dblStockSolutionVolume + dblDilutingSolventVolume, uevML, cboTotalVolume.ListIndex)
If dblFinalTotalVolume < 0 Then
txtTotalVolume.Text = ""
Else
FormatTextBox txtTotalVolume, dblFinalTotalVolume
End If
End With
mUpdatingTotalSolventVolume = False
End Sub
Private Sub PopulateComboBoxes()
Dim strAmountString As String, strVolumeString As String, strMolarString As String
Dim intIndex As Integer
' Load Amount types in the Combo Boxes
SetDelayUpdate True
PopulateComboBox cboAction, True, "Convert Amounts|Find Concentration|Dilution Calculations", 1
PopulateComboBox cboDilutionMode, True, "Find Required Dilution Volumes|Find Required Total Volume|Find Final Concentration|Find Initial Concentration", 0
strAmountString = "Moles|Millimoles|microMoles|nanoMoles|picoMoles|femtoMoles|attoMoles|Kilograms|Grams|Milligrams|Micrograms|Pounds|Ounces|Liters|Deciliters|Milliliters|Microliters|Nanoliters|Picoliters|Gallons|Quarts|Pints"
PopulateComboBox cboFrom, True, strAmountString, uamGrams
PopulateComboBox cboTo, True, strAmountString, uamMoles
Debug.Assert cboFrom.ListCount = Val(objMMConverter.AmountsUnitListCount)
strVolumeString = "Liters|Deciliters|Milliliters|Microliters|Nanoliters|Picoliters|Gallons|Quarts|Pints"
PopulateComboBox cboVolume, True, strVolumeString, uevML
PopulateComboBox cboStockSolutionVolume, True, strVolumeString, uevML
PopulateComboBox cboDilutingSolventVolume, True, strVolumeString, uevML
PopulateComboBox cboTotalVolume, True, strVolumeString, uevML
strMolarString = "Molar|milliMolar|microMolar|nanoMolar|picoMolar|femtoMolar|attoMolar|mg/dL|mg/mL|ug/mL|ng/mL|ug/uL|ng/uL"
PopulateComboBox cboConcentration, True, strMolarString, ummcMolar
PopulateComboBox cboDilutionConcentrationInitial, True, strMolarString, ummcMolar
PopulateComboBox cboDilutionConcentrationFinal, True, strMolarString, ummcMolar
With cboMassError
.Clear
.AddItem "m/z"
.AddItem "ppm"
.ListIndex = 1 ' ppm
End With
With cboMH
.Clear
.AddItem "M (uncharged)"
.AddItem "[M+H]1+"
For intIndex = 2 To 9
.AddItem "[M+" & Trim(intIndex) & "H]" & Trim(intIndex) & "+"