Click here to Skip to main content
15,895,142 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: deleteing from database Pin
Jon_Boy3-Jun-09 6:27
Jon_Boy3-Jun-09 6:27 
GeneralRe: deleteing from database Pin
chrispowell123453-Jun-09 22:12
chrispowell123453-Jun-09 22:12 
GeneralRe: deleteing from database Pin
Dave Kreskowiak4-Jun-09 1:22
mveDave Kreskowiak4-Jun-09 1:22 
GeneralRe: deleteing from database Pin
chrispowell123454-Jun-09 2:18
chrispowell123454-Jun-09 2:18 
QuestionTransaction deadlock crash + vb.net 2008 Pin
Pankaj Garg3-Jun-09 3:41
Pankaj Garg3-Jun-09 3:41 
AnswerRe: Transaction deadlock crash + vb.net 2008 Pin
Kschuler3-Jun-09 4:59
Kschuler3-Jun-09 4:59 
AnswerRe: Transaction deadlock crash + vb.net 2008 Pin
Dave Kreskowiak3-Jun-09 5:40
mveDave Kreskowiak3-Jun-09 5:40 
QuestionAny suggestions or guidelines with using Class Modules in VBA for MS Word / Excel Pin
psionic20093-Jun-09 0:27
psionic20093-Jun-09 0:27 
Hi there,

This would be my first post that is basically asking/requesting points of view from various Bloggers/experts from this site whom I welcome to comment on coding principles rather than talking about code specific. Big Grin | :-D

Some background information to introduce this subject, basically I am working on a project that simplifies automating a summary form in MS Word that involves in several processes along the way. It has text forms fields and few check boxes that is associated to several bookmarks.

I can use VBA code to collect information from these bookmarks and make control structure decisions given input from users. I have a drop down lists that I will have to use MS Access instead of an array code to fill them up as I was shocked to find VBA telling me that 25 continuation lines is the maximum when I wanted to fill an array for over 120 items. bummer! WTF | :WTF:

Anyway, I know about object oriented programming and have seen the benefits, especially from books on Word / Excel VBA suggesting a Class Module using examples of employees with time sheet objects.

Trouble is, I couldn't confidently use it but I wanted to so I can organise the forms like objects and put the results into a collection like Word / Excel organises data. I tend to be cautious as I used to write code like I would write COBOL structured programming (I used to do this mind you!)

I would use those examples provided from books to develop my own patch of code that achieves a sort of re-factoring about approximately 40 lines of VBA module code when the user clicks the button that starts the module.

Let's give a fictional example that give you an idea or essence of my module project at work to show you what I mean and I wanted to re-factor these ideas from this CommandButton1 module into a Class Module that simplifies duplicate code.

Please forgive me for lacking any comments in the code.

Here are my questions - What's the best approach in converting this into a VBA class module?

What guidelines would people offer from their experience into turning modules into class modules?

This code works when a button on the form is pressed after entering information into three fields in Word.

<br />
Sub CommandButton1_Click()<br />
Dim objA as Document<br />
Dim strB as String<br />
Dim strC as String<br />
Dim strD as String<br />
Dim blnB as Boolan<br />
Dim blnC as Boolan<br />
Dim blnD as Boolan<br />
<br />
Set objA = ActiveDocument<br />
<br />
blnB = false<br />
blnC = false<br />
blnD = false<br />
<br />
strB = objA.FormField("FieldA").Result<br />
<br />
if strB = "Somebody" then<br />
blnB = True<br />
<br />
strC = objA.FormField("FieldB").Result<br />
<br />
if strC = "Anybody" then<br />
blnC = True<br />
<br />
strD = objA.FormField("FieldC").Result<br />
<br />
if StrD = "Otherbody" then<br />
blnD = True<br />
<br />
If blnB then<br />
  if blnC then<br />
     if blnD then<br />
       Save this file<br />
     else<br />
       Msgbox "Error entering Field C"<br />
     end if<br />
  else  <br />
    msgbox "Error enter Field B"<br />
  end if<br />
else<br />
  msgbox "Error enter Field A"<br />
end if<br />
  <br />
End Sub<br />


Regards, Psionic
Questionproblem in sending a mail through CDO configuration using macro in Excel Pin
haijimsonjose2-Jun-09 23:25
haijimsonjose2-Jun-09 23:25 
AnswerRe: problem in sending a mail through CDO configuration using macro in Excel Pin
EliottA3-Jun-09 3:17
EliottA3-Jun-09 3:17 
QuestionWhere does the custom Outlook Commandbar come from? Pin
Sonhospa2-Jun-09 22:26
Sonhospa2-Jun-09 22:26 
AnswerRe: Where does the custom Outlook Commandbar come from? Pin
Dave Kreskowiak3-Jun-09 3:19
mveDave Kreskowiak3-Jun-09 3:19 
NewsRe: Where does the custom Outlook Commandbar come from? Pin
Sonhospa3-Jun-09 4:04
Sonhospa3-Jun-09 4:04 
GeneralRe: Where does the custom Outlook Commandbar come from? Pin
Dave Kreskowiak3-Jun-09 12:37
mveDave Kreskowiak3-Jun-09 12:37 
QuestionHow to create Digital Sign For My Application Pin
Anubhava Dimri2-Jun-09 20:42
Anubhava Dimri2-Jun-09 20:42 
AnswerRe: How to create Digital Sign For My Application Pin
Christian Graus2-Jun-09 21:29
protectorChristian Graus2-Jun-09 21:29 
GeneralRe: How to create Digital Sign For My Application Pin
Anubhava Dimri2-Jun-09 21:37
Anubhava Dimri2-Jun-09 21:37 
AnswerRe: How to create Digital Sign For My Application Pin
Kschuler3-Jun-09 3:18
Kschuler3-Jun-09 3:18 
GeneralRe: How to create Digital Sign For My Application Pin
Anubhava Dimri3-Jun-09 18:11
Anubhava Dimri3-Jun-09 18:11 
GeneralRe: How to create Digital Sign For My Application Pin
0x3c03-Jun-09 21:49
0x3c03-Jun-09 21:49 
GeneralRe: How to create Digital Sign For My Application Pin
Anubhava Dimri3-Jun-09 22:17
Anubhava Dimri3-Jun-09 22:17 
QuestionVB 6.0 Language while Interpreting [modified] Pin
vhassan2-Jun-09 20:37
vhassan2-Jun-09 20:37 
Questionhow do i see/change the events of a form? Pin
neodeaths2-Jun-09 19:54
neodeaths2-Jun-09 19:54 
AnswerRe: how do i see/change the events of a form? Pin
Dave Kreskowiak3-Jun-09 2:02
mveDave Kreskowiak3-Jun-09 2:02 
GeneralRe: how do i see/change the events of a form? Pin
neodeaths4-Jun-09 5:58
neodeaths4-Jun-09 5:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.