|
a=26
how to set b=2?
In c, you can do
b=a/10;
I try
b=CInt(a/10) in VB, and I got b=3. Thank you.
<italic>Work hard, Work effectively.
|
|
|
|
|
In C if “a “ was assigned the value of 2.6 and you executed the statement b=a/10, then b would have the value of 0.26 if it was a double and if b was an integer then it would have the value of 0.
In Visual Basic .Net we have two division operators, the / meaning floating point division and the \ meaning integer division.
Dim a As Double = 12
Dim b As Double ‘ Holds the value of integer division
Dim c As Double ‘ Holds the value of floating point division
b = a \ 5 ‘ b would have the value of 2.0
c = a / 5 ‘ c would have the value of 2.4
I hope this was of some help.
|
|
|
|
|
According to my help document IsKeyColumn is one of the columns returned when you execute a data reader for GetSchemeTable
When I execute this code:
reader = cmdSel.ExecuteReader(CommandBehavior.KeyInfo)
Dim dt As DataTable = reader.GetSchemaTable
While reader.Read()
If dt.Rows(idx).Item("IsKeyColumn") = True then
.
.
.
I get this error on the "If" line
Column 'IsKeyColumn' does not belong to table SchemaTable.
Any help??????
Thanks,
-Len Miller
"If I had eight hours to chop down a tree, I'd spend six sharpening my axe."
-Abraham Lincoln
|
|
|
|
|
As it turns out - I dumped the schematable to see the column names
CONTRARY to my documentation, the column is named "IsKey" not "IsKeyColumn"
grrrmph....
If anyone cares, I attached code that dumps the schematable:
reader = cmdSel.ExecuteReader(CommandBehavior.KeyInfo)
Dim dt As DataTable = reader.GetSchemaTable
Dim schemaTable As DataTable
Dim myProperty As DataColumn
Dim str As String = ""
Dim myField As DataRow
schemaTable = reader.GetSchemaTable()
For Each myField In schemaTable.Rows
'For each property of the field...
For Each myProperty In schemaTable.Columns
'Display the field name and value.
str = String.Concat(str, _
String.Format("[{0}]=[{1}]{2}" _
, myProperty.ColumnName _
, myField(myProperty).ToString() _
, Microsoft.VisualBasic.ControlChars.CrLf) _
)
Next
Next
MessageBox.Show(str)
Thanks,
-Len Miller
"If I had eight hours to chop down a tree, I'd spend six sharpening my axe."
-Abraham Lincoln
|
|
|
|
|
Does anyone know how VB translates extended keycodes (exspecialy on WinXP). When ALT+0176 is pressed, the keycode should be 0xB0 but we get 0xFFFFB0FF instead.
Signed: John R. Shaw
Blast: I must remember to find my password!
|
|
|
|
|
Hi John,
I am in no way a Hex expert, but the similarity of 0xB0 and 0xFFFFB0FF make me wonder if .NET is just specifying a longer format of the same value. dotNET also has several conversion classes that may help in the process, like converting from Hex to Decimal or bit conversions.
Probably of no help, but I hope it sparks some ideas,
Scott Page
|
|
|
|
|
Hi..Can you please tell me how can I shutdown my computer or restart it in VB.net.Please Help!!
Snaker
|
|
|
|
|
There is a function in user32.dll which is called ExitWindowsEx. The MSDN documentation for the function can be found at This Web Site. You must declear the external function, something like this
Private Declare Function MyExitWindowsEx Lib "User32" Alias "ExitWindowsEx" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
then call the MyExitWindowsEx function with the correct parameters as per the document.
Good luck
|
|
|
|
|
That can be put to good use put a program with the close script in it at form load and put it in the startup folder.
Ouch!
1. Out of clutter, find simplicity.
2. From discord, find harmony.
3. In the middle of difficulty lies opportunity.
Albert Einstein
three rules of work
|
|
|
|
|
hello,
i am trying to parse a multiline text box, but i can't seem to figure out how to do it.
for example, if in the first text (txtInput) box i have:
hello there,
this
is
fun
i would want to print out something like:
hello there, this is fun
in the 2nd text box (txtOutput).
i thought that i could use some sort of a while statement like:
while (input.IndexOf(vbCrLf) <> -1)
where input = txtInput.text
but i'm not sure how to increment line by line. if this was a stream reader, i could do:
While (stream.Peek <> -1)
but i don't know if anything like that exists for multiline text box reading. it seems to me that the value of the textbox just becomes a string.
thanks in advance,
michael
|
|
|
|
|
hello,
i figured it out. within my while statement, i added:
input = input.Substring(input.IndexOf(vbCrLf) + 2)
in order to get to the next line. The "+ 2" confused me, as I would have thought a "+ 1 " would be sufficient. However, now I'm on the right track!
thank you,
michael
//txtIn and txtOut are my text boxes
Dim input As String = txtIn.Text
Dim currentLine As String
Dim output As String
Dim i As Integer = 1
While (input.IndexOf(vbCrLf) <> -1)
currentLine = input.Substring(0, input.IndexOf(vbCrLf))
output &= "line number: " & i & " " & currentLine & vbCrLf
input = input.Substring(input.IndexOf(vbCrLf) + 2)
i += 1
End While
txtOut.Text = output
|
|
|
|
|
Is possible to use visual basic .net to create a small file that is not required .net framework?
Lisa
|
|
|
|
|
Hi Lisa;
If your question is can you run a VB.Net program on a system that supports the
.Net Framework and have that program produce a file that can be viewed or used
on a system that does not have the .Net Framework, for example text, bmp, XML
files and others then the answer is yes. But if you are asking if you can run a
.Net program on a system that does not have the .Net Framework then the answer
is no. One of the most important part of the .Net Framework is the CLR “Common
Language Runtime”. This block of code provides the environment in which .Net
programs are executed in. You can download the .Net Framework from Microsoft
free of charge at, click here -> .Net Framework Download This download includes all that is needed to run
applications developed under .Net Framework.
I hope I have been of some help.
|
|
|
|
|
I have a borderless form with a yellow transparency key to give my form a custom shape. When i compile it on my computer it works but when i install it onto another the yellow part shows up. Any ideas????
|
|
|
|
|
If you could provide the code you used for the transparancy of the form, it would help me to understand the problem much better.
Thanks.
|
|
|
|
|
I didnt create it through code. What i did was, i created a BMP image and
set it as my forms background. Some of the bmp is yellow, set to be my transparent
part. I just set the forms property "Transparency Key" = Yellow
It works on my development computer but when i install it on another the yellow
part shows up. Ive already given up on this but if you can figure it out i will
sing at your wedding or do something. Thank you
|
|
|
|
|
Is is possible to send/receive data calls using the PCCSDK ? If so, does anyone
have any examples, and if not, waht is the best way to accomplish it.
|
|
|
|
|
I am subclassing a VB ListBox so that depending on whether my item in a listbox linked to a collection and the HasData property of the linked item in the collection is TRUE then set the ListItem to display coloured red and in italics. This all works as planned, except that I want to also display the CheckBox to the left of the items text. Because I am drawing the item text myself (so that I can set the font and colour) I cannot see how to get the CheckBox to also be displayed.
Could some kind person please explain how I can display the CheckBox as well.
My Subclassing code is as follows:
Public Function WindowsWndProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long<br />
<br />
<br />
Select Case uMsg<br />
<br />
Case WM_DRAWITEM<br />
<br />
'<br />
' This is only called for the ListBox on the frmClaimsSelection.<br />
' I tried to access the name of the class of the control<br />
' but that didn't seem to work. If anyone has any ideas let me know.<br />
'<br />
<br />
Dim strClass As String<br />
Dim sz As Long<br />
Dim DIS As DRAWITEMSTRUCT<br />
Dim CWP As CWPSTRUCT<br />
Dim sString As String<br />
Dim lRet As Long<br />
Dim lFont As Long<br />
Dim nHeight As Long<br />
Dim tSize As SIZE<br />
Dim fdwItalic As Long<br />
Dim lpszFace As String<br />
Dim lCount As Long<br />
<br />
lpszFace = "MS Sans Serif"<br />
fdwItalic = 1<br />
nHeight = 8<br />
<br />
Call CopyMemory(CWP, ByVal lParam, LenB(CWP))<br />
Call CopyMemory(DIS, ByVal lParam, Len(DIS))<br />
<br />
'<br />
' Get name of class of window of the control being drawn<br />
'<br />
sz = GetClassName(CWP.hwnd, ByVal strClass, 128)<br />
strClass = Left$(strClass, sz)<br />
<br />
' Select Case strClass ' See above comment.<br />
'<br />
' Case "ThunderListBox"<br />
' With DIS<br />
'<br />
' End With<br />
'<br />
' End Select<br />
<br />
With DIS<br />
'<br />
' Get the text, indicated by DrawItemStruct.iItemID,<br />
' from the listbox.<br />
'<br />
sString = Space$(128)<br />
lRet = SendMessage(.hwndItem, LB_GETTEXT, .itemID, ByVal sString)<br />
sString = Left$(sString, lRet)<br />
<br />
' Get the collection of claims, so that we can check if the<br />
' claims items has been generated by existance of Taxpoint data,<br />
' if it hasn't then display in italics and colured.<br />
If MainForm.ClaimsSelectionForm.ClaimsSelectionCollection(DIS.itemID).HasData Then<br />
fdwItalic = 1<br />
Else<br />
fdwItalic = 0<br />
End If<br />
<br />
<br />
<br />
'<br />
' Create a logical font based on the font specified<br />
' in the listbox.<br />
'<br />
lFont = CreateFont(nHeight, 0, 0, 0, 0, fdwItalic, 0, 0, 0, 0, 0, 0, 0, lpszFace)<br />
'<br />
' Select the font into the new device context.<br />
' Compute the width and height of a string of text.<br />
' Set the height of the listbox item accordingly.<br />
'<br />
Call SelectObject(.hdc, lFont)<br />
Call GetTextExtentPoint32(.hdc, sString, Len(sString), tSize)<br />
<br />
Call SendMessage(.hwndItem, LB_SETITEMHEIGHT, .itemID, ByVal tSize.cy)<br />
'<br />
' Set the color of the text of the list item<br />
' based on whether the item is selected or not.<br />
'<br />
Call SetBkColor(.hdc, GetSysColor(COLOR_WINDOW))<br />
If fdwItalic Then<br />
Call SetTextColor(.hdc, &HFF&)<br />
Else<br />
Call SetTextColor(.hdc, GetSysColor(COLOR_WINDOWTEXT))<br />
End If<br />
<br />
<br />
End With<br />
'<br />
' Draw the text in the listbox.<br />
'<br />
With DIS.rcItem<br />
Call TextOut(DIS.hdc, .Left, .Top, sString, Len(sString))<br />
End With<br />
<br />
Call DeleteObject(lFont)<br />
WindowsWndProc = 0<br />
<br />
<br />
End Select<br />
<br />
<br />
End Function
|
|
|
|
|
Hi Everyone,
I'm in need of suggestions. I have this asp.net multiple combo box form that filters a datagrid. My dilemma is I have seven combos with begin and end range, and the user can select any combination no business rules given for the sequence. I have to build this SQL String on the fly but I'm finding myself using more if conditions than I care for has anyone done something like this in an elegant manner. Again there are no business rules that govern this filter screen. The only thing I have control of is to make sure a user doesn't hit submit and loads the entire dataset which is say something like 400,000 rows with 100+ columns being return.
Thanks in advance
|
|
|
|
|
I trying to replace abc to def(TextFile)
Private Sub Command1_Click()
Call WriteToTxt("FlatFile", 2, "abc", "def")
End Sub
Public Sub WriteToTxt(strTable As String, intField As Integer, strFind As String, strReplace As String)
Dim intFileHandle As Integer
Dim intFileHandle2 As Integer
Dim strRETP As String
Dim sFieldArray As Variant
Dim found As Boolean
found = False
intFileHandle = FreeFile
Open "C:\" & strTable & ".txt" For Input As #intFileHandle
intFileHandle2 = FreeFile
Open "C:\" & strTable & ".txt.tmp" For Output As #intFileHandle2 ' temp file
While Not EOF(intFileHandle)
Line Input #intFileHandle, strRETP
If Not found Then
FieldArray = Split(strRETP, "|")
If FieldArray(0) = strFind Then (Im geting Error on this line saying Subscript out of range)
FieldArray(intField) = strReplace
strRETP = Join(FieldArray, "|")
found = True
End If
End If
Print #intFileHandle2, strRETP
Wend
Close #intFileHandle
Close #intFileHandle2
Kill "C:\" & strTable & ".txt" ' delete original
Name "C:\" & strTable & ".txt.tmp" As "C:\" & strTable & ".txt" ' rename temp file
End Sub
|
|
|
|
|
Hi;
This is what is happening in your code snipped.
The error is not happening on the line that the debugger lead you to believe, it is on the next line of code “FieldArray(intField) = strReplace”. What I believe is happening is that in the file FlatFile.txt you have a line that may read as “abc|???” and when the line “FieldArray = Split(strRETP, "|")” executes FieldArray looks like this
FieldArray(0) = “abc”
FieldArray(1) = “???”
so when the program executes the line “FieldArray(intField) = strReplace” it fails with Subscript out of range because intField has a value of 2 but the valid index into FieldArray are 0 and 1. This is what is known as off by one error. Index on an array start at zero not one.
I hope this has been of some help.
-Fernando Soto
|
|
|
|
|
Actually, he's getting the error on the correct line. Split will return an array no matter what. But, if it is executed on an empty string, the array will be returned with no elements in it. This will result in an out of bounds exception if you try to access any element in the array, even if the indexer used is 0, since there are no elements in the array.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You are correct that is a possibility. But once he checks for blank lines he will run into the next problem, off by 1 error.
|
|
|
|
|
This is the documented result of running Split on an empty string. Split will return an array that has no entries in it at all. Enclose your split code in an error handler or check to see if strRETP is empty before running split on it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have never run into this before, maybe you have an answer for me.
I built a script that will send a remote command window to a computer, for the configuration of the Dell Remote Access Card.
Obviously, SERVER, is my variable for the remote computer I want to connect to, and PASSWORD, is my variable for the password I want to set for the account.
The part where I need to use my PASSWORD variable is where I have issues. If I wscript.echo the line back, it is literally putting “ & PASSWORD & “ as my command to be issued. I need my variable PASSWORD in quotes, plus the quote at the end for the command being issued.
------------------------------------------------------------
Set objWMIService = GetObject ("winmgmts:\\" & SERVER & "\root\cimv2:Win32_Process")
errReturn = objWMIService.Create ("cmd /k racadm config -g cfgUserAdmin -o cfgUserAdminPassword -i 2 "" & PASSWORD & """, Null, Null, intProcessID)
------------------------------------------------------------
|
|
|
|
|