首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

有哪位朋友能帮小弟我把下面的VB代码改写成C#代码下,本人不懂VB哈 多谢

2012-04-02 
有哪位朋友能帮我把下面的VB代码改写成C#代码下,本人不懂VB哈 谢谢Public Sub ToSheet_Example()Dim vsoSh

有哪位朋友能帮我把下面的VB代码改写成C#代码下,本人不懂VB哈 谢谢
Public Sub ToSheet_Example()
 
  Dim vsoShapes As Visio.Shapes 
  Dim vsoShape As Visio.Shape 
  Dim vsoConnectTo As Visio.Shape 
  Dim vsoConnects As Visio.Connects 
  Dim vsoConnect As Visio.Connect 
  Dim intCurrentShapeIndex As Integer
  Dim intCounter As Integer
  Set vsoShapes = ActivePage.Shapes
 
  'For each shape on the page, get its connections.
  For intCurrentShapeIndex = 1 To vsoShapes.Count 

  Set vsoShape = vsoShapes(intCurrentShapeIndex) 
  Set vsoConnects = vsoShape.Connects 

  'For each connection, get the shape it connects to.
  For intCounter = 1 To vsoConnects.Count 

  Set vsoConnect = vsoConnects(intCounter) 
  Set vsoConnectTo = vsoConnect.ToSheet 

  'Print the name of the shape the 
  'Connect object connects to. 
  Debug.Print vsoConnectTo.Name 

  Next intCounter 

  Next intCurrentShapeIndex
 
End Sub
 



[解决办法]

C# code
void ToSheet_Example(){   Visio.Shapes vsoShapes;  Visio.Shape vsoShape;  Visio.Shape vsoConnectTo;  Visio.Connects vsoConnects;    Visio.Connect vsoConnect ;  int intCurrentShapeIndex;  int intCounter;  vsoShapes = ActivePage.Shapes;   //For each shape on the page, get its connections.  for(intCurrentShapeIndex = 1;intCurrentShapeIndex <=vsoShapes.Count;intCurrentShapeIndex ++){  vsoShape = vsoShapes(intCurrentShapeIndex) ;  vsoConnects = vsoShape.Connects ;  //For each connection, get the shape it connects to.  for(intCounter = 1; intCounter <=vsoConnects.Count ;intCounter ++)  {  vsoConnect = vsoConnects(intCounter) ;  vsoConnectTo = vsoConnect.ToSheet ;  //Print the name of the shape the   //Connect object connects to.   Console.WriteLine(vsoConnectTo.Name);   }  } } 

热点排行