how pass a parameter to onload function??
<body onLoad="myFunction(<%=myVar%>)">
It crashes.
The parameter is a vb variable defined with Dim
The function is a vbscript function
Urgent HELP
Hi. I have the following code:
Imports System.IO
Public Class Blah
Public Sub New()
InitializeComponent()
Dim watcher As New FileSystemWatcher("C:\")
watcher.EnableRaisingEvents = True
AddHandler watcher.Changed, AddressOf watcher_Changed
End Sub
Private Sub watcher_Changed(ByVal sender As Object, ByVal e As FileSystemEventArgs)
MsgBox(e.FullPath)
End Sub
End Class
When I run it and save changes to a file on my C drive, the code works great, except it executes the watcher_Changed() method four times. Any idea why? The changeType is "4" every time.
Thanks.
Private Sub cmdClear_Click()
Dim Confirm As Integer
Confirm = MsgBox("Are you sure you want clear this Sheet?", vbYesNo, "WARNING: Date Changed")
If Confirm = 6 Then
Sheets("OPV").Activate
'Sheets("OPV").Activate
Sheets("OPV").Range("B4:BZ1000").ClearContents
Sheets("OPV").Range("B4:BZ1000").Interior.Pattern = xlNone
Sheets("OPV").Activate
Sheets("OPV").Range("B4").Activate
MsgBox " Done .. ", vbInformation, "Clear ......"
End If
End Sub
I am using vb.net 2005. i am trying to set report groupings of a crystal report at runtime based on user defined options. MSDN says this:
Dim FieldDef As FieldDefinition
FieldDef =
Report.Database.Tables.Item(0).Fields.Item(comboBox1().Text)
Report.DataDefinition.Groups.Item(0).ConditionField = FieldDef
but error shows invalid group number
how to solve this?
Suppose I have some code that looks like this:
Private Sub MySub()
dim blnFlag as Boolean
blnFlag = False
for each item in collection
if item.Name = "Mike" then
blnFound = true
exit for
endif
next item
End Sub
Now - the blnFLag = False assignment is not actually necessary - booleans are initialised as false, but I think it's inclusion makes the code easier to read. What's your opinion?
question: how can i bind the same vector, lets say o=c(1,2,3,4) mutiple times to get a matrix like
o=array(c(1,2,3,4,1,2,3,4,1,2,3,4), dim(c(4,3))
o
[,1] [,2] [,3]
[1,] 1 1 1
[2,] 2 2 2
[3,] 3 3 3
[4,] 4 4 4
in a nicer way then: o=cbind(o,o,o) and maybe more generalized (dublicate()??
I need this to specifiy colors for elements in textplot()
thx a lot
How to make a link button visible after another button has been clicked in asp.net(vb) in button_click()
it says error as "Object reference not set to an instance of an object."
i've done this in my code
Protected Sub InsertButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim receipt As LinkButton = FormView1.FindControl("LinkButton1")
' receipt.Enabled = "true"
' receipt.EnableTheming = "true"
' receipt.EnableViewState = "true"
receipt.Visible = "true"
End Sub
what should be the parameter for create object the following code
dim a
set a=CreateObject("Collection") //getting a runtime error saying ActiveX
//component can't create object: 'Collection
a.add(CreateObject("Collection"))
a.Items(0).Add(1)
MsgBox(a.Items(0).count)
MsgBox(a.Items(0).Item(0))
Can I convert my VB code to C++? How can I do it?
This is my VB code:
Dim OpenFileDialog1 As New OpenFileDialog
With OpenFileDialog1
.CheckFileExists = True
.ShowReadOnly = False
.Filter = "All Files|*.*|Bitmap Files (*)|*.bmp;*.gif;*.jpg"
.FilterIndex = 2
If .ShowDialog = DialogResult.OK Then
' Load the specified file into a PictureBox control.
PictureBox1.Image = Image.FromFile(.FileName)
End If
End With
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim allowedChars As String = "0123456789$,"
If allowedChars.IndexOf(e.KeyChar) = -1 Then
' Invalid Character
e.Handled = True
End If
End Sub
this code accept only digits and its working like a charm but if i typed a wrong number its not allowing me to use the delete or the backspace on the keyboard how to solve this problem ?
I need to have the following : (name1 + "a") + (name2 + "a") + ...
Dim separator() As String = {"|"}
myString.Split(separator, StringSplitOptions.None).SomeLinq(...)
I don't know what to add at the end to add an "a" to each element...
I have done
Dim qd as querydef
set qd = Querydefs("MyQuery")
set qd.sql = "..."
In debug qd.sql has been updated but the physical MyQuery still contains the old sql.
How to update this physical query ?
I'm trying to write a simple/small Windows Communication Foundation service application in Visual Basic (but I am very novice in VB) and all the good examples I've found on the net are written in C#. So far I've gotten my WCF service application working but now I'm trying to add callback functionality and the program has gotten more complicated. In the C# example code I understand how everything works but I am having trouble translating into VB the portion of code that uses a delegate. Can someone please show the VB equivalent?
Here is the C# code sample I'm using for reference:
namespace WCFCallbacks
{
using System;
using System.ServiceModel;
[ServiceContract(CallbackContract = typeof(IMessageCallback))]
public interface IMessage
{
[OperationContract]
void AddMessage(string message);
[OperationContract]
bool Subscribe();
[OperationContract]
bool Unsubscribe();
}
interface IMessageCallback
{
[OperationContract(IsOneWay = true)]
void OnMessageAdded(string message, DateTime timestamp);
}
}
namespace WCFCallbacks
{
using System;
using System.Collections.Generic;
using System.ServiceModel;
public class MessageService : IMessage
{
private static readonly List<IMessageCallback> subscribers = new List<IMessageCallback>();
//The code in this AddMessage method is what I'd like to see re-written in VB...
public void AddMessage(string message)
{
subscribers.ForEach(delegate(IMessageCallback callback)
{
if (((ICommunicationObject)callback).State == CommunicationState.Opened)
{
callback.OnMessageAdded(message, DateTime.Now);
}
else
{
subscribers.Remove(callback);
}
});
}
public bool Subscribe()
{
try
{
IMessageCallback callback = OperationContext.Current.GetCallbackChannel<IMessageCallback>();
if (!subscribers.Contains(callback))
subscribers.Add(callback);
return true;
}
catch
{
return false;
}
}
public bool Unsubscribe()
{
try
{
IMessageCallback callback = OperationContext.Current.GetCallbackChannel<IMessageCallback>();
if (!subscribers.Contains(callback))
subscribers.Remove(callback);
return true;
}
catch
{
return false;
}
}
}
}
I was thinking I could do something like this but I don't know how to pass the message string from AddMessage to DoSomething...
Dim subscribers As New List(Of IMessageCallback)
Public Sub AddMessage(ByVal message As String) Implements IMessage.AddMessage
Dim action As Action(Of IMessageCallback)
action = AddressOf DoSomething
subscribers.ForEach(action)
'Or this instead of the above three lines:
'subscribers.ForEach(AddressOf DoSomething)
End Sub
Public Sub DoSomething(ByVal callback As IMessageCallback)
'I am also confused by:
'((ICommunicationObject)callback).State
'Is that casting the callback object as type ICommunicationObject?
'How is that done in VB?
End Sub
I'm writing a macro, but because I'm working for first time in vb, I faced problems.
My code:
Cells (1, 1).Select
Dim tempvar As Integer
tempvar = Val(Selection.Value) // error
Selection.Value = tempvar + 1
What my code should be:
Cells(1,1).Value+=1
I get error "type mismatch". How do I accomplish that?
I am coding in Visual Basic. I am using a checkbox control. Now depending on its checked property I need to set/unset a bit column in a SQL Server database. Here's the code:
Try
conSQL.Open()
Dim cmd As New SqlCommand("update Student set send_mail = " + _
sendemailCheckBox.Checked.ToString + " where student_id = '" _
+ sidnolabel.Text + "'", conSQL)
cmd.ExecuteNonQuery()
Finally
conSQL.Close()
End Try
The send_mail attribute is of bit datatype. This code is not working.
How do I go about it?
Hello how can I have like a catalog for a property in .net VB .. I mean if i have
Property funcion(ByVal _funcion As Int16) As Int16
Get
Return _funcion
End Get
Set(ByVal value As Int16)
_funcion = value
End Set
End Property
I want to be able to assign to this property a limited number of options.
Example ..
Dim a as trick (the class )
a.funcion = (and get a list of possible attributes) ...
Thanks !!!
What function in Excel simply takes a string parameter and runs the command? It would work just like the OK button in the Start - Run dialog.
Dim myCommand as String
myCommand = "excel C:\Documents and Settings\JohnDoe\Desktop\test.xls"
Run(myCommand)
I'm creating a reporting application, and our customers are going to need to generate some pretty big reports which require quite a bit of memory. Ive been in a re-factoring mood lately, so I was wondering what the best way to access the properties of another open form would be(The reporting viewer opens in a new form.) So far I have:
Dim form As MainSelections
form = My.Application.OpenForms(2)
yay or nay.
Thanks
my application builds a pdf with images
in the solution explorer i added a folder called pics and dropped all the images there
when i run the program from my computer, there are no problems, but when i had a different user install the application they get this error:
here's how i am including the image:
Dim jpeg2 As Image = Image.GetInstance(Application.StartupPath & "\pics\1.jpg")
i am using the itextsharp library
why is the user having this problem?
I have used the connection string below but I am getting an error when trying to create a table
Dim ConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strFName + _
";Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX=1"""
Cannot modify the design of table 'tablename'. It is in a read-only database.
Why does the following display 12/31/1600 ???
Imports System.IO
Module Module1
Sub Main()
Dim fi As New FileInfo("DocFiles\phillips_phone_number.txt")
Console.WriteLine(fi.FullName)
Console.WriteLine(fi.LastAccessTime.ToShortDateString)
Console.ReadKey()
End Sub
End Module
I have a code like this:
Dim strResponses As String
strResponses = Forms!frmResponses.QstnID.OpenArgs
If Len(strResponses) 0 Then
Me![QstnID].DefaultValue = Me.OpenArgs
End If
When I run it, its gives error 438. Can someone help me to know where the error is?
I'm trying to copy an existing sheet in my workbook and then I want to use the copied sheet to run the rest of my code.
(Sheet3 is the existing sheet, S_Temp is the copied sheet)
Dim s_Temp as string
Sheet3.copy
Activesheet.name = S_Temp
Sheets("S_Temp").Range("A1").value = "Test"
How can I reference to the copied sheet?
I am having an issue with referencing the sheet name through =Branded!$A$1 Notation in VBA. For a while I have passed in simple sheet names like:
Dim SheetName As String
SheetName = "Pizza"
("=" & SheetName & "!$A$1")
This has worked fine, but recently I passed in "Tier 1" and of course this notation broke. Is there any fix or workaround for this? It Think it's because of the space, the number or both....