How to get stringbuilder to assign values to custom textboxes on a New e-mail window Rudolph Scott wrote:
The textboxes are on an Outlook 2007 new e-mail form. The default boxes are Subject, cc, Body, things like that. I additionally added some more textboxes to this form and named them (names like Caller, Surname,Building, etc, etc). Just like my code assigns the text value 'PhoneCall' to the subject box and displays the value in the subject box when the new mail message form loads , I want to assign a values to my custom boxes. For instance, I have a box called 'Caller' and I want to assign a text value to it and have it displayed in this box. I am doing this using Visual Basic in Visual Studio 2005.
Is it possible to use stringbuilder in this case Or do I need to use another method
Hi Rudolph,
Please check the System.Net.Mail.MailMessage Class.
http://msdn2.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx
It represents an e-mail message that can be sent using the SmtpClient class.
The MailMessage class has these associated properties as below.
When an e-mail message is to be sent, basic properties will be specified, likewise, when you receive an e-mail message, you can directly retrieve relevant property value to your TextBox control.
SmtpClient can be used to send Email message.
PopClient can be used to retrieve Email messages.
Mail part
Property
Sender
From
Recipient
To
Carbon copies (CC)
CC
Blind carbon copies (BCC)
Bcc
Attachments
Attachments
Subject
Subject
Message body
Body
Send Email sample.
Public Shared Sub CreateMessageWithAttachment( ByVal server As String ) ' Specify the file to be attached and sent. Dim file As String = "data.xls" ' Create a message and set up the recipients. Dim message As MailMessage = New MailMessage( "jane@contoso.com" , "ben@contoso.com" , "Quarterly data report." , "See the attached spreadsheet." )
'Create the file attachment for this e-mail message. Dim data As Attachment = New Attachment(file, MediaTypeNames.Application.Octet)
' Add the file attachment to this e-mail message. message.Attachments.Add(data)
'Send the message. Dim client As SmtpClient = New SmtpClient(server)
' Add credentials if the SMTP server requires them. client.Credentials = CredentialCache.DefaultNetworkCredentials client.Send(message) End Sub
References:
Send Email sample
POP3 Email Client (.NET 2.0)
Sending and Receiving Email
Regards,
Martin Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Hide Password Characters? Is there a way to hide the characters the user enters into a text box, in the same way other applications do when entering a password Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Help!!! This code is killing my Computer. Hi Soyuz,
Just because something is done, even prevalently doesn't mean it doesn't have a negative impact on people. Sexism has always been prevalent. Pornography is prevalent and that doesn't mean that women do not feel that our bodies or pieces of our bodies are up for sale or to be seen as objects to be dominated.
Thank you for your consideration. Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
About Uninstall directory in Registry If your application installs perfectly with other setups, I'd blame the target computer, not your application. Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
SendKeys Help... I'm trying to have my program execute a keypress when I push this certain button, but for the life of me I cannot find the keypress code for the spacebar, I've tried {Spacebar}, {SPACE}, {Space}, {SPACEBAR} and { }, none of them worked for me. Could anyone help me out with this Here is my code thus far...
Code Snippet
Private Sub Button1_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SetCursorPos(740, 690)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
System.Threading.Thread.Sleep(2000)
SendKeys.SendWait( "{SPACE}" )
End Sub Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Mp3 Coding Check the '.net' tab.
It came with my standard VB express install
as far as I can recollect. Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Of Pictureboxes, Transparency, Movement and Backgrounds lonlon_malon,
Have you read the post titled Image Background Removal with the link: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1016243&SiteID=1
I think it helps. As nobugz said: You can do it with the Bitmap.MakeTransparent() method. I added a bitmap to the resources, named SampleBitmap, with a white background and added a panel to the form:
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint Dim bmp As Bitmap = My.Resources.SampleBitmap bmp.MakeTransparent(Color.White) e.Graphics.DrawImage(bmp, New Rectangle(0, 0, Panel1.Width, Panel1.Height)) End Sub
There are lots of ways to tweak this code; in this example, I stretch the image to fit the panel. You can use other overloads of Graphics.DrawImage() to display it just the way you want it...
Hope that your problem has been solved :-) Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
problem with msdn Peter Ritchie wrote: The last MSDN library that worked with Visual C++ 6.0 was the October 2001 version, which is no longer downloadable.
I am not surprised that it would not have changed since October 2001. However, the Visual C++ 6.0 MSDN library continued to be provided in MSDN subscriptions as late as 2003 (I have such a DVD in my archives), usually as a companion to a newer MSDN library that required a post-6.0 Visual Studio for automatic integration. Visual Studio 6.0 Professional and its Service Pack 5 were distributed as recently as the August 2003 Disc 2353 (DVD), one I've kept around "just-in-case."
We agree on the consequences: the library is no longer available from Microsoft except in the form of MSDN on-line archive materials which, fortunately, are available to non-MSDN subscribers such as our inquiring student and the teacher. Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Visual Studio 2005 Express - how do i add and use active X controls? What I need to do is add an active x control to my project and use the methods from that active x control. I know how to use the object browser, add a COM component (although the one I need is missing from the list) and see it's methods. How do I add it to a form There's no Object Container control in VB2005. The help file says the Web control can be substituted 'in some cases'. I can use that and point the URL to the active x file I want to use, but then I have no way accessing its methods. Alex Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Bug?: Unwanted C4819 Well, you know, it is a warning. I don't think VC++ 2005 Express Edition has any way to tell that you are using Latin1. I think that is why it checks the default code page you are running under.
There's probably a #pragma clause that you could add to your #if material to suppress that particular warning.
Two points:
1) The warning seems to be from the preprocessor: after preprocessing the code is removed.
2) Probably because of above it cannot be disabled by #pragma, which works after preprocessing.
So what do you see in your program's output when you compile and run it with VC++ under default codepage 936 Surely not '¡ê'
Of course not. This is just a fake example, instead of the real code. In real code it could be converted to Unicode and output by TextOutW. And my point is that the building environment needs not to be the same as run-time environment (which might use really the English locale).
I don't think the ' ' comes from the compiler. It comes from the run-time system when it doesn't recognize a code for the code-page you have installed.
It is from the compiler. I checked the assembly output by /Fa :-).
The message is misleading. The advice about saving the file (that is, your test.c file) in Unicode format (UTF-8) is fine, but not so easy to do. You can use notepad to do it, and if the file is pasted into a blank page the way I did with your sample, it appears that the file is indeed saved in UTF-8 (the pound-Sterling symbol saves and restores just fine). The compiler can't tell you are using Latin1 because there are no markers that indicate the intended code as there are for UTF-8 and UTF-16 files on Windows.
Exactly. The advice is useless really. Saving the file as Unicode eliminates the warning, but producing code differently. And it is not feasible at all for cross-platform coding.
Do notice that in my original case (and example) the character literal is not used on Windows. It is really for EBCDIC systems! Since it is not used, one does not expect anything from the compiler, let alone an overwhelming (my original case occurs in a header file), unsuppressable warning! Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Example of tabbed webbrowsing
Tom, that's rather nice. I can tell it's based on the standard webbrowser control because it has the webbrowser's bugs.
one of which becomes apparent http://www.vanishingpointgame.com/ here. click on the left box and then click on the tab the extends. Then repeat that with IE.
However, I have a bug that you don't that's driving me crazy. You may want to take a look at www.freewebs.com/reneecc
in the forum search boxes.
Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
radio button listbox Hi,
thanks i tried using this but then it doesnt suit .net Compact
i am developing a PDA application. any idea how do i have a radio button listbox
thanks
Johnson Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
How to set up Status Label for Browser Hi,
What is the code for the status label so that it shows what the progress bar is doing like in IE. For example in IE where it says "Downloading 1 out of __ images and then leads to "Done". Please, This is my first ever success program and I want to make it good. May you please put it in full code. I will learn on whatever code you give me. Thanks! Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Running a program in conjunction with a batch file You can use the command line arguments in your application.
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '//Get The command Line Arguments If My.Application.CommandLineArgs.Count > 0 Then For Each s As String In My.Application.CommandLineArgs Next Else End If End Sub End Class
Doing something like this allows you to write you application so that if you provide it with command line arguments can determine there contents and run a process - if you dont provide any then you can run interactively....
Ultimately this determination will be made when the form load event fires.
Then you have to make your application process the command line arguments and run the process without user involvement. To me it sounds like a console application type of process but if you want to implement as a windows application then its pretty easy. Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
How Can I delete a read only folder In the name of Allah
Hi all ....
I've a small question
''
How Can I delete a read only folder
i used
my.computer.filesystems.deletedirectory(Dir)
but didnt work because the dir is readonly Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
problems to use WMI classes with VB 2005 express. True. I forgot the Option Strict on.
I work on WinXP sp2 too.
Thank you. Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Adding Number in VB LOL, thats because the + operand is concatenate for string types, u need to convert them first, use Cint(textquantity1.text) etc etc (assuming your textboxes do not cross the integer threshhold, if so, use Clng or Cdbl). Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
show desktop Not really I'm afraid.
Just done a quick Google and the impression I get is that it isn't going to be easy! There doesn't seem to be anything in managed code to help. Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
so gentle Well let's assume I would use another type of GUI then. What type would you suggest and how can I save and retrieve the user/data inputs to and from a file that is not beyond my abilities to accomplish
I can¡¯t speak for your abilities, but what you are proposing is going to require a lot of computational expertise. You¡¯ve mentioned several issues, so let¡¯s consider data issues first and then the GUI issues.
What you have described is unlikely to be meaningfully resolved with any kind of flatfile solution. I do not know how many sets of data you are proposing. If it¡¯s just a few, then an XML file, written by the XML writer may be of interest. An XML file is a self-describing hierarchically organized data system, readable with Notepad. Internally an XML file looks like this:
< xml version="1.0" encoding="utf-8" standalone="yes" > <Directory> <Service> <ServiceName>Abuse and Neglect Services</ServiceName> <Description>Help for an abused or neglected child</Description> <Para1>The organizations listed below provide services for abused or neglected children and their families.</Para1> <Para2>For each of the organizations listed below you will find information about the ages they serve, the languages spoken and eligibility criteria.</Para2> <Para3>More complete information about these organizations's location, contact person, hours of operation and a description of their programs can be found in Part II - Directory of Organizations starting on page xx.</Para3> <Narrative>More complete information about these organization's locations, contact person, hours of operation, fees charged and a description their programs can be found in part II, the directory of organizations starting on page PAGENUM</Narrative>
<ServiceDetail> <SrvDetail>General</SrvDetail> <Organization> <Organization-Phone>Associates For Renewal In Education (555) 111-9424</Organization-Phone> <Ages>2-6; 7-12; 13-2(Also adults)</Ages> <Languages><![CDATA[English;]]></Languages> <Eligibility><![CDATA[All]]></Eligibility> </Organization> <Organization> <Organization-Phone>Center for Adoptive Families (of AdoptionsTogether, Inc.)* (555) 111-2900</Organization-Phone> <Ages>0-6; 7-12; 13-18</Ages> <Languages><![CDATA[Portuguese; Spanish]]></Languages> <Eligibility><![CDATA[Children and their families affected by adoption or foster\line care]]></Eligibility> </Organization> <Organization> <Organization-Phone>Center for Child Protection and Family Support, Inc. (555) 111-6175</Organization-Phone> <Ages>4-6; 12; 13-17</Ages> <Languages><![CDATA[English]]></Languages> <Eligibility><![CDATA[Child victims of neglect, physical abuse, sexual abuse or\line with a report from the police regarding child abuse or\line neglect. ;]]></Eligibility> </Organization> <Organization>
As you can see, XML supports replicated entities quite well and be well suited to your application if there is not a large number different sets of data, like Agency A, Agency B, etc. Variables are known by labels. If there is, I think a database is indicated be it either Access or SQL Express.
So let¡¯s talk about a GUI solution. The interesting thing about this was that all the data was entered via a single textbox. We know the questions will be the same for each Organization so I was write software that know how to prompt for the data and to collect it.
Each question has a structure associated with that systematically prompts the user for information. Descriptors for doing that might look like this:
InqArray(ciOID).DBModifiableField = False
InqArray(ciOID).MandatoryField = False
InqArray(ciOID).UserModifiableField = False
InqArray(ciOID).CmbIndex = -1
InqArray(ciOID).DisplayAsChoice = False
InqArray(ciOID).[Protected] = True
InqArray(ciOID).DBFieldName = "O_ID"
InqArray(ciOID).ControlType = Cntrltyp.None
TextBoxTemplate.DBModifiableField = True ' Set up the template
TextBoxTemplate.MandatoryField = False ' Make the default - User's Options to fill in the form
TextBoxTemplate.ControlType = Cntrltyp.Textbox
TextBoxTemplate.UserModifiableField = True
TextBoxTemplate.DisplayAsChoice = True
TextBoxTemplate.tbmaxlen = 50 ' in characters
TextBoxTemplate.tbNoofLines = 1 ' 20 pixels perline
InqArray(ciName) = TextBoxTemplate
InqArray(ciName).tbmaxlen = 100
InqArray(ciName).CmbIndex = 0 ''
InqArray(ciName).MandatoryField = True
InqArray(ciName).Name = OrgFields(0)
InqArray(ciName).Instruction = "FQLR|'s Name."
InqArray(ciName).DBFieldName = "O_Name"
InqArray(ciContact) = TextBoxTemplate
InqArray(ciContact).CmbIndex = 1 ''
InqArray(ciContact).Name = OrgFields(1)
InqArray(ciContact).MandatoryField = True
InqArray(ciContact).Instruction = "FQLR|'s contact person's name."
InqArray(ciContact).DBFieldName = "O_Contact"
InqArray(ciAddress) = TextBoxTemplate
InqArray(ciAddress).CmbIndex = 2 ''
InqArray(ciAddress).Name = OrgFields(2)
InqArray(ciAddress).MandatoryField = True
InqArray(ciAddress).Instruction = "FQLR| street address."
InqArray(ciAddress).DBFieldName = "O_Address"
As you can see this structure supplies information for prompting the user as well as collecting and storing the data. Once it¡¯s all collected it¡¯s committed to the database.
There were also back and forward controls to allows the user to go back and make corrections. These suggestions I think would suit you well. Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Quotes in a string Yes,
C# defines the following character escape sequences:
Code Snippet \' - single quote, needed for character literals \" - double quote, needed for string literals \\ - backslash \0 - Unicode character 0 \a - Alert (character 7) \b - Backspace (character 8) \f - Form feed (character 12) \n - New line (character 10) \r - Carriage return (character 13) \t - Horizontal tab (character 9) \v - Vertical quote (character 11) \uxxxx - Unicode escape sequence for character with hex value xxxx \xn[n][n][n] - Unicode escape sequence for character with hex value nnnn (variable length version of \uxxxx) \Uxxxxxxxx - Unicode escape sequence for character with hex value xxxxxxxx (for generating surrogates)
Thanks Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Add DBNull to date field in database? I actually meant to say monthcalendar, not datetimepicker.
the datetimepicker will always show a value in it. I'm not sure if you can prevent it or not.
but the monthcalendar is not automatically shown in a textbox so you can add the selected date to a textbox if one is chosen.
After a while all the names start to sound the same on some things.
Maybe i am just tired here lately
And about messenger, i don't do any chat. I strictly stay in the forum. Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Reading/Writing .dat file Bill,
The application already does this - in fact - could you look at my last post - it might give you an idea or two - the code is also posted there.
Thanks,
Mike Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Validate text box using code You could.
Select case e.keychar
Case keycharOfInterest1
Case keycharOfInterest2
end select
is tidier. Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Formulas like excel I hope so ! I have my fingers crosed and I do think it's the right direction. The script control is the interpretive part. Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
csv to binary? WriteAllText added a Byte Order Marker (BOM)
(The 3 extra bytes)
Whereas WriteAllBytes did not.
Also, just to nitpick, you are storing the file as binary (bin)
not as a real Comma Separated Value (csv).
It is only held as a comma separed value inside of the program.
So, a more apt file extension would be 'bin'. Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
i want different buttons I added to what I said. I've done that with the tabs and provided a URL for you to see them. Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Draw point in a tab page I meant "how are you doing the drawing". Are you using CreateGraphics or handling an event. Could we see some code My code works - the point is at the top left of the tab page and visible. It works by handling the paint event for the tab page, everything is set up for you, and you are given a Graphics object to draw with. Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Calculation formulas In my wee banking database I have the expected three columns ie: deposit, withdrawal and balance. I have never used formulas before in excell, programming or anything and after searching on the web for the last two days to find out about them I am at my wits end.
Could somebody please explain how to get these columns to add/delete and update the balance column. and where/how to put the code. Do I use the Formulas property in the database property for the balance column if so what do I type.
Im desperate to make this part work so any help would be great.
Diane Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
ToLower (lowercase) are you telling the computer to replace the value with one you have already calculated
you can teach the computer how to calculate each value without telling it to memorise every roman numeral... just like you know MCMXCII is 1992
whenever a smaller value is preceded by a larger CM or XC (100=C being less than 1000=M and 10=X less than 100=C) then you know to add the greater to the total sum and subtract the lesser... eg. add a thousand but subtract a hundred.
MCMXCII is really : M - C + M - X + C + I + I
no need to memorise the whole thing...
here a couple of functions that do this...
' at the top of your code you need this user defined type (udt)
Private Structure udtRomanNumeral
Dim value As Short
Dim symbol As String
End Structure
Public Function getRomanSymbolValue( ByVal strSymbol As String ) As Int16
Static udrNumerals(6) As udtRomanNumeral
Static bolInit As Boolean
Dim intCounter As Integer
' this function gets a symbol I, V, X, L, C, D or M and returns their integer values 1, 5, 10, 50, 100, 500 or 1000 respectively
If Not bolInit Then
bolInit = True
udrNumerals(0).value = 1
udrNumerals(0).symbol = "I"
udrNumerals(1).value = 5
udrNumerals(1).symbol = "V"
udrNumerals(2).value = 10
udrNumerals(2).symbol = "X"
udrNumerals(3).value = 50
udrNumerals(3).symbol = "L"
udrNumerals(4).value = 100
udrNumerals(4).symbol = "C"
udrNumerals(5).value = 500
udrNumerals(5).symbol = "D"
udrNumerals(6).value = 1000
udrNumerals(6).symbol = "M"
End If
getRomanSymbolValue = -1
For intCounter = 0 To 6
If strSymbol = udrNumerals(intCounter).symbol Then
getRomanSymbolValue = udrNumerals(intCounter).value
Exit Function
End If
Next intCounter
End Function
Public Function evaluateRomanNumeral( ByVal strRoman As String ) As Int16
' this function receives a string and evaluates it as a roman numeral and then returns its integer equivalent
' it does this by chopping off the leading characters. Since roman symbols decrease in value from left to right (except when subtracting 1x10^x, e.g. IV, IX, XL, XC, CD or CM)
' then add this value to total, unless it is followed by another symbol of greater value(see previous line)
Dim intTemp, intRank As Integer
Dim numRank As Short
Dim intCounter As Integer
Dim intLeadingCounter As Integer
Dim strSymbol, strThisSymbol As String
Dim strNextSymbol As String
Dim intValue, intThisValue As Integer
Dim intNextValue As Integer
Dim intRank1 As Integer
Dim intRank2 As Integer
Dim strPartialRomant As String
Dim bolLoop As Boolean
Dim strRanking As String
Dim strRememberInputParameter As String
On Error GoTo handler
strRememberInputParameter = strRoman
strRanking = "IVXLCDM" ' this is used to determine whether one symbol is ranked higher than another by testing the result of instr() for two adjacent symbols
For intCounter = 1 To Len(strRoman)
If InStr(strRanking, Mid(strRoman, intCounter, 1)) = 0 Then
evaluateRomanNumeral = 0 ' if a symbol appears in the input parameter 'strRoman' that does is not a valid Roman Numeral symbol then the output is zero and exit function
Exit Function
End If
Next intCounter
startEvaluateRomanNumeralLoop:
Do While Len(strRoman) > 0
strThisSymbol = Mid(strRoman, 1, 1)
If Len(strRoman) > 1 Then
If Mid(strRoman, 2, 1) <> strThisSymbol Then
' if the first symbol (we are chopping off from the left as we go) is lesser in rank than its following symbol then we need to subtract the first and add the second
intRank1 = InStr(strRanking, strThisSymbol)
intRank2 = InStr(strRanking, Mid(strRoman, 2, 1))
If intRank2 > intRank1 Then
' iv, ix, xl, xc, cd, or cm and such
evaluateRomanNumeral = evaluateRomanNumeral - getromanSymbolValue(strThisSymbol)
evaluateRomanNumeral = evaluateRomanNumeral + getromanSymbolValue(Mid(strRoman, 2, 1))
strRoman = Mid(strRoman, 3)
GoTo startEvaluateRomanNumeralLoop
End If
End If
End If
' since we did not GoTo startEvaluateRomanNumeralLoop we know that this first symbol is the highest in the remaining string and must be added
' count the number of times it appears, multiply that number by its value and add it to the total count
intLeadingCounter = 0 : bolLoop = True
Do
If Len(strRoman) > 0 Then
If Mid(strRoman, 1, 1) = strThisSymbol Then
intLeadingCounter = intLeadingCounter + 1
strRoman = Mid(strRoman, 2)
Else
bolLoop = False
End If
Else
bolLoop = False
End If
Loop While bolLoop
intValue = getRomanSymbolValue(strThisSymbol)
evaluateRomanNumeral = evaluateRomanNumeral + intLeadingCounter * intValue
Loop
' here we test our result with this function's complement, if all is well then we're happy
If Not UCase(getRomanNumeral(evaluateRomanNumeral)) = UCase(strRememberInputParameter) Then
evaluateRomanNumeral = 0
End If
Exit Function
handler:
Stop
Resume
End Function
Public Function getRomanNumeral( ByVal lngValue As Integer ) As String
' this function receives an integer value and returns its Roman numeral equivalent in the form of a string
' it does this by subtracting the value of the highest ranking symbol as it keeps a tally of the count
Static udrNumerals(6) As udtRomanNumeral
Static bolInit As Boolean
Dim intValue As Short
Dim intTemp, intRank As Object
Dim numRank As Short
On Error GoTo handler
If Not bolInit Then
bolInit = True
udrNumerals(0).value = 1
udrNumerals(0).symbol = "I"
udrNumerals(1).value = 5
udrNumerals(1).symbol = "V"
udrNumerals(2).value = 10
udrNumerals(2).symbol = "X"
udrNumerals(3).value = 50
udrNumerals(3).symbol = "L"
udrNumerals(4).value = 100
udrNumerals(4).symbol = "C"
udrNumerals(5).value = 500
udrNumerals(5).symbol = "D"
udrNumerals(6).value = 1000
udrNumerals(6).symbol = "M"
End If
getRomanNumeral = ""
If lngValue > 3899 Then ' there is a limit to the input value... anything that requires a symbol for 5000 (D with a bar above) does not work... MMMDCCCXCIX ... 3899
Exit Function
End If
intValue = lngValue
Do While intValue > udrNumerals(6).value
intTemp = intValue Mod udrNumerals(6).value
numRank = intTemp / udrNumerals(6).value ' this is the number of 1000s
getRomanNumeral = getRomanNumeral & udrNumerals(6).symbol 'L
intValue = intValue - udrNumerals(6).value
Loop
' now the value is less than 1000
intRank = 5
Do While intValue > 0
If intRank Mod 2 = 1 Then
' this is either 5, 50 or 500
intTemp = intValue Mod udrNumerals(intRank).value
If intValue >= udrNumerals(intRank).value Then ' >= 5
If intValue >= udrNumerals(intRank + 1).value - udrNumerals(intRank - 1).value Then ' >= 9
getRomanNumeral = getRomanNumeral & udrNumerals(intRank - 1).symbol & udrNumerals(intRank + 1).symbol ' IX
intValue = intValue + udrNumerals(intRank - 1).value - udrNumerals(intRank + 1).value ' -1+10
ElseIf intValue >= udrNumerals(intRank).value + 3 * udrNumerals(intRank - 1).value Then ' >= 8
getRomanNumeral = getRomanNumeral & udrNumerals(intRank).symbol & udrNumerals(intRank - 1).symbol & udrNumerals(intRank - 1).symbol & udrNumerals(intRank - 1).symbol ' VIII
intValue = intValue - udrNumerals(intRank).value - 3 * udrNumerals(intRank - 1).value ' + 5 + 3
ElseIf intValue >= udrNumerals(intRank).value + 2 * udrNumerals(intRank - 1).value Then ' >= 7
getRomanNumeral = getRomanNumeral & udrNumerals(intRank).symbol & udrNumerals(intRank - 1).symbol & udrNumerals(intRank - 1).symbol ' VII
intValue = intValue - udrNumerals(intRank).value - 2 * udrNumerals(intRank - 1).value ' + 5 + 2
ElseIf intValue >= udrNumerals(intRank).value + udrNumerals(intRank - 1).value Then ' >= 6
getRomanNumeral = getRomanNumeral & udrNumerals(intRank).symbol & udrNumerals(intRank - 1).symbol ' VI
intValue = intValue - udrNumerals(intRank).value - udrNumerals(intRank - 1).value ' + 5 + 1
Else ' >= 5
getRomanNumeral = getRomanNumeral & udrNumerals(intRank).symbol ' V
intValue = intValue - udrNumerals(intRank).value ' + 5
End If
Else
intRank = intRank - 1
End If
Else
' this is either 1, 10, 100
If intValue >= udrNumerals(intRank).value Then ' >= 1 but < 5
If intValue >= udrNumerals(intRank + 1).value - udrNumerals(intRank).value Then ' >= 4
getRomanNumeral = getRomanNumeral & udrNumerals(intRank).symbol & udrNumerals(intRank + 1).symbol ' IV
intValue = intValue + udrNumerals(intRank).value - udrNumerals(intRank + 1).value
ElseIf intValue >= 3 * udrNumerals(intRank).value Then ' >= 3
getRomanNumeral = getRomanNumeral & udrNumerals(intRank).symbol & udrNumerals(intRank).symbol & udrNumerals(intRank).symbol ' III
intValue = intValue - 3 * udrNumerals(intRank).value
ElseIf intValue >= 2 * udrNumerals(intRank).value Then ' >= 2
getRomanNumeral = getRomanNumeral & udrNumerals(intRank).symbol & udrNumerals(intRank).symbol ' II
intValue = intValue - 2 * udrNumerals(intRank).value
Else ' >= 1
getRomanNumeral = getRomanNumeral & udrNumerals(intRank).symbol ' III
intValue = intValue - udrNumerals(intRank).value
End If
Else
intRank = intRank - 1
End If
End If
Loop
Exit Function
handler:
Stop
Resume
End Function
Public Function isARomanNumeral( ByVal strWord As String ) As Boolean
' this function tests if the input is a valid roman numeral
isARomanNumeral = False
If Len(strWord) > 0 Then
If UCase(Trim(getRomanNumeral(evaluateRomanNumeral(strWord)))) = UCase(Trim(strWord)) Then
isARomanNumeral = True
End If
End If
End Function Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
DataBinding + Manual Field Hi Jon1s,
Thanks first of all for the help. However, I am still not clear of what to do. I followed your code but still it does not seem to work. As I mentioned I am using Access. My database name is Customers and have the following fields:
- CustomerID (Number Integer) - Primary Key
- CustomerType (Text)
- CustomerName (Text)
Please note that for existing records (put directly through Access) I have no problem updating using DataBinding, but I need to add new records with the CustomerID. I have the following questions if possible.
- First of all, it is giving an error on the connection string altough I copied it from Project settings as you said. There is a waved line under the dot and the 4 indicating the error. " OLEDB .4 " . This makes myCon invalid.
- In the SQLtext variable do I need to put @par1 or put the controls names directly like I did.
- The i variable not defined.
- I first use a button to add new record as shown in the code below. This only adds a CustomerID which is ok but I need to modify the ID and store it. How can I do it.
- If I am already using DataBinding to open the database, why do I need to use SQL command to open the database again, why can't I just add to the data already in the memory and store it.
- Finally if possible, can you have a look at code and suggest the correct code.
many thanks.
Code Snippet
Public Class frmCustomer
Private Sub frmCustomer_Load( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase .Load
Me .CustomersTableAdapter.Fill( Me .SmartDataSet.Customers)
End Sub
Private Sub tsbCustSave_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbCustSave.Click
'Code workinf fine for updating existing records only.
'CustomersBindingSource.EndEdit()
'CustomersTableAdapter.Update(SmartDataSet.Customers)
Dim SQLtext As String
Dim myCon As New OleDbConnection( My .Settings.Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Smart.mdb)
SQLtext = "INSERT INTO Customers (CustomerType, CustomerName) VALUES(@cmbCustType, @txtCustName)"
Dim myCom As New OleDb.OleDbCommand(SQLtext, myCon)
Dim val1 = Me .cmbCustType.Text
Dim val2 = Me .txtCustName.Text
myCom.Parameters.Add( New OleDb.OleDbCommand( "@par1" , OleDbType.VarChar)).Value = val1
myCom.Parameters.Add( New OleDb.OleDbCommand( "@par2" , OleDbType.VarChar)).Value = val2
myCon.Open()
i = myCom.ExecuteNonQuery()
MessageBox( "Number of Records Added: " & i & "" )
myCon.Close()
End Sub
Private Sub tsbCustClose_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbCustClose.Click
Me .Close()
End Sub
Private Sub tsbCustNew_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbCustNew.Click
CustomersBindingSource.MoveLast()
CustomersBindingSource.AddNew()
End Sub
Private Sub tsbCustDelete_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbCustDelete.Click
CustomersBindingSource.RemoveCurrent()
End Sub
End Class Tag: Visual Basic Express Edition Virtual Hardware Visual Studio Express Editions
Ok, but I'm not looking to do anything with Virtual PC, just specific virtual hardware. I know it can be done, because I have programs written in VB that create virtual CD drives, virtual removable disks, etc..
In addition, your post didn't answer my question, so please don't mark it as an answer for me.
Virtualizing hardware device requires writing device drivers. Typical examples are a virtual printer that outputs anything printed to a PDF file or virtual network cards that establish a VPN connection over the Internet. You can't write device drivers in VB.NET, it requires C++ and the DDK. If you have done this previously, perhaps you mean something else
I personally have not, I'm running programs that have done that. I don't know what the device drivers were written [with/in] however, so at least that explains this for me.
That answers my question: learn to work with C++ and the DDK. Thanks nobugz.